dsab Posted May 15, 2009 Share Posted May 15, 2009 I bet this is going to be a really simple error but i dont understand why i get thie error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/home/shopinbrooklin/.public_html/index.php on line 19 from this code: <?php require_once("./inc/connect_db.php"); require_once("./header.html"); $index_header1 = $_GET['index_header1']; $index_body1 = $_GET['index_body1']; $index_header2 = $_GET['index_header2']; $index_body2 = $_GET['index_body2']; $query = "SELECT header, body, header2, body2 FROM index "; //print("$mysql_link $query<br />"); $mysql_stuff = mysql_query($query, $mysql_link); while($row = mysql_fetch_row($mysql_stuff)) { $index_header1 = htmlspecialchars(stripslashes($row[0])); $index_body1 = htmlspecialchars(stripslashes($row[1])); $index_header2 = htmlspecialchars(stripslashes($row[2])); $index_body2 = htmlspecialchars(stripslashes($row[3])); print(" <table border=\"0\"> <tr> <td colspan=\"2\" background=\"images/comp3_04.png\"><h1 class=\"style1\">$index_header1</h1> <hr /> <div align=\"justify\" class=\"style8\"> <p class=\"style9\"><span class=\"style10\"><img id=\"myimg\" src=\"images/shopping.png\" width=\"185\" height=\"185\" align=\"right\"/> $index_body1 </span> <br /> <br /> *SHOP IN BROOKLIN!* <br /> Brought to you by C&C Connections <br /> <br /> <br /> <br /> </p> </div> <div align=\"left\"></div></td> </tr> <tr> <td colspan=\"2\" valign=\"top\"><h1 class=\"style1\">$index_header2</h1> <hr /> <p class=\"style1 style10\"> $index_body2 <a href=\"crier.html\">more ></a></p> </td> </tr> </table> "); } require_once("./footer.html"); ?> Link to comment https://forums.phpfreaks.com/topic/158297-mysql_fetch_row-error/ Share on other sites More sharing options...
wildteen88 Posted May 15, 2009 Share Posted May 15, 2009 You have an error with your query. Change $mysql_stuff = mysql_query($query, $mysql_link); to $mysql_stuff = mysql_query($query, $mysql_link) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/158297-mysql_fetch_row-error/#findComment-834905 Share on other sites More sharing options...
Maq Posted May 15, 2009 Share Posted May 15, 2009 Means your query is probably failing. Change this line to 1 line: $query = "SELECT header, body, header2, body2 FROM index"; And this line to: $mysql_stuff = mysql_query($query, $mysql_link) or die(mysql_error()); Tell me what the output is. Link to comment https://forums.phpfreaks.com/topic/158297-mysql_fetch_row-error/#findComment-834906 Share on other sites More sharing options...
Ken2k7 Posted May 15, 2009 Share Posted May 15, 2009 index is a MySQL reserved word. Link to comment https://forums.phpfreaks.com/topic/158297-mysql_fetch_row-error/#findComment-834959 Share on other sites More sharing options...
Maq Posted May 15, 2009 Share Posted May 15, 2009 Ok then, use this: $query = "SELECT header, body, header2, body2 FROM `index`"; Link to comment https://forums.phpfreaks.com/topic/158297-mysql_fetch_row-error/#findComment-834961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.