zorkah Posted July 2, 2013 Share Posted July 2, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/279777-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-cwampwwwrodorowphp-on-line-56/ Share on other sites More sharing options...
DaveyK Posted July 2, 2013 Share Posted July 2, 2013 $query = mysql_query("SELECT * FROM rodocontent ORDER BY 'efternamn' ASC"); returns false, try: $query = mysql_query("SELECT * FROM rodocontent ORDER BY 'efternamn' ASC") or die(mysql_error()); ALSO, there are like a THOUSAND records on this issue on google. Do your own research please. Quote Link to comment https://forums.phpfreaks.com/topic/279777-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-cwampwwwrodorowphp-on-line-56/#findComment-1438996 Share on other sites More sharing options...
ginerjm Posted July 2, 2013 Share Posted July 2, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/279777-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-cwampwwwrodorowphp-on-line-56/#findComment-1439042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.