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

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.