Jump to content

[SOLVED] mysql_fetch_row error


rscott7706

Recommended Posts

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?  8)  ???

Link to comment
https://forums.phpfreaks.com/topic/110984-solved-mysql_fetch_row-error/
Share on other sites

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");

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.