Jump to content

( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\rodorow.php on line 56


zorkah

Recommended Posts

Hello good people of php freaks!


Im really really new to this php stuff, but is seems fun and all but i'v got so many problems I dont know were to start so I guess this is a good place to start:


I get this error code :
 

( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\rodorow.php on line 56

Im gonna bold were the code is corrupt :

here is the code:
 

 

<!DOCTYPE html>
<html lang="en">
<head>
<title>Row Test</title>
<link rel="stylesheet" href="rowstyle.css" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
<!-- Anslut till databasen samt hämta ut $query som sorteras på ID i stigande ordning -->
 
<?php
mysql_connect ("localhost", "root", "rodopass") or die ('Kan inte ansluta till databasen för att: ' . mysql_error());
mysql_select_db ("rodoschema");
 
$query = mysql_query("SELECT * FROM rodocontent ORDER BY 'efternamn' ASC");
 
?>
 
</head>
 
 
 
<body>
<div id="logos">
<img src="rodo/rodologga.png" alt="Midroc Rodoverken" />
</div>
 
<div>
<table>
<thead>
<td class="efternamn">Efternamn</td>
<td class="fornamn">Förnamn</td>
<td class="veckodag" colspan="2">Måndag</td>
<td class="veckodag" colspan="2">Tisdag</td>
<td class="veckodag" colspan="2">Onsdag</td>
<td class="veckodag" colspan="2">Torsdag</td>
<td class="veckodag" colspan="2">Fredag</td>
</thead>
<tr id="secondaryheader">
<td class="efternamn"></td>
<td class="fornamn"></td>
<td class="delavdagfm">Förmiddag</td>
<td class="delavdagem">Eftermiddag</td>
<td class="delavdagfm">Förmiddag</td>
<td class="delavdagem">Eftermiddag</td>
<td class="delavdagfm">Förmiddag</td>
<td class="delavdagem">Eftermiddag</td>
<td class="delavdagfm">Förmiddag</td>
<td class="delavdagem">Eftermiddag</td>
<td class="delavdagfm">Förmiddag</td>
<td class="delavdagem">Eftermiddag</td>
</tr>
 
<!-- En while-loop some skriver ut varje rad i tabellen från $query  -->
 

 

 
<?php
while ($row = mysql_fetch_array($query)) {
echo "
<tr class='tablecontent'>
<td class='efternamn'>".$row['efternamn']."</td>
<td class='fornamn'>".$row['fornamn']."</td>
<td class='delavdagfm'>".$row['manfm']."</td>
<td class='delavdagem'>".$row['manem']."</td>
<td class='delavdagfm'>".$row['tisfm']."</td>
<td class='delavdagem'>".$row['tisem']."</td>
<td class='delavdagfm'>".$row['onsfm']."</td>
<td class='delavdagem'>".$row['onsem']."</td>
<td class='delavdagfm'>".$row['torfm']."</td>
<td class='delavdagem'>".$row['torem']."</td>
<td class='delavdagfm'>".$row['frefm']."</td>
<td class='delavdagem'>".$row['freem']."</td>
</tr>";}
 
?>
</table>
</div>
</body>
 
</html>
 
/
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
Thanks and as I said - Im super mega new to this so any help would be wonderful

 

best of regards!


David
 
Link to comment
Share on other sites

Advice for newbies:

 

Look up the syntax and usage of any function before you implement it.  It will save you TIME and FRUSTRATION.

(Note: the url to the php manual ("the bible") is at the top of this forum.)

 

For functions that return a value, be sure to check that the value doesn't indicate an error (ESPECIALLY queries!) before you try to use your expected results.

 

It's great that you are intrigued and excited about learning php, but the big part of getting into this is Learning and you won't do that if you don't do some work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.