rscott7706 Posted June 19, 2008 Share Posted June 19, 2008 Hello all, I have a problem with a table snippet. I have a page that works fine using the following code: <?php $db = mysql_connect("masterli.ipowermysql.com", "", ""); mysql_select_db("masterli_rates"); $query = "SELECT * FROM costs"; $result = mysql_query($query) or die(mysql_error()); ?> <?php echo "<font face=\"times new roman\">", "<size=\"1\">"; echo "<table>"; $query = mysql_query("SELECT Item, Price, Postage, Notes FROM costs"); while(list($Item, $Price, $Postage, $Notes)=mysql_fetch_row($query)){ echo " <tr> <td width=500, align: top, cell spacing: 3px>$Item</td> <td width=20, vertical-align: top, cell spacing: 3px align=right>$$Price</td> <td width=100, vertical-align: top, cell spacing: 3px>$Postage</td> <td width=400, vertical-align: top, cell spacing: 3px>$Notes</td> </tr>"; } echo "</table>"; ?> Here is the link: http://www.masterliens.com/prices-alone.php So, I copy this exact code to another site and re-address the necessary fields, now it won't work. And I get the following message: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/s/d/r/sdrental/html/automotive-page.php on line 92 Here is the code from the second site: <?php echo "<font face=\"verdana\">"; echo "<br />"; $db = mysql_connect("p50mysql99.secureserver.net", "", ""); mysql_select_db("tools_equip"); $query = "SELECT * FROM inventory"; $result = mysql_query($query) or die(mysql_error()); ?> <?php echo "<font face=\"arial\">", "<size=\"1\">"; echo "<table>"; $query = mysql_query("SELECT Desc, Model, Pic FROM inventory"); while(list($Desc, $Model, $Pic)=mysql_fetch_row($query)){ echo " <tr> <td width=50, align: top, cell spacing: 3px>$Desc</td></tr> <td width=200, vertical-align: top, cell spacing: 3px align=left>$Model</td> <td width=50, vertical-align: top, cell spacing: 3px>$Pic</td></tr> </tr>"; } echo "</table>"; ?> The first site is hosted by IpowerWeb, and is using: PHP Version 4.4.7 The second site is hosted by GoDaddy and is using: PHP Version 4.3.11 Any ideas? ??? Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/ Share on other sites More sharing options...
DarkWater Posted June 19, 2008 Share Posted June 19, 2008 $query = mysql_query("SELECT Desc, Model, Pic FROM inventory"); Change to: $query = mysql_query("SELECT Desc, Model, Pic FROM inventory") OR die(mysql_error()); Then post your error here. =/ Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569426 Share on other sites More sharing options...
menriquez Posted June 19, 2008 Share Posted June 19, 2008 it looks like you don't have a userid and password for your mysql_connect function call... - mark Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569428 Share on other sites More sharing options...
abdfahim Posted June 19, 2008 Share Posted June 19, 2008 you cannot write $query = mysql_query("SELECT Desc, Model, Pic FROM inventory"); because Desc is a mySQL command and so the above query will definitely gives an error. Either you should change the column name or re-write the query as follows $query = mysql_query("SELECT `Desc`, `Model`, `Pic` FROM inventory"); Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569429 Share on other sites More sharing options...
DarkWater Posted June 19, 2008 Share Posted June 19, 2008 it looks like you don't have a userid and password for your mysql_connect function call... - mark He probably deleted them for this post. =) His error is caused by an invalid query. Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569445 Share on other sites More sharing options...
rscott7706 Posted June 19, 2008 Author Share Posted June 19, 2008 DarkWater, menriquez and abdbuet, Thanks for your quick responses. menriquez - I left out log on info intentionally. abdbuet - your solution worked fine, thank you all so much!!! Ron Scott Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569447 Share on other sites More sharing options...
DarkWater Posted June 19, 2008 Share Posted June 19, 2008 @rscott7706: I'd change the column name instead of relying on backtick (`) "escaping" (getting around a reserved word), because I think that only MySQL supports ` `. So change the column name. D: Link to comment https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/#findComment-569448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.