Jump to content

One query works but the other doesnt??


OriginalSunny

Recommended Posts

Hi,
I have used the following code for my queries:

$connect = connect_to_db("con.inc");
$query = "SELECT * FROM purc WHERE
ID='{$_SESSION['ID']}'";
$result = mysql_query($query,$connect)
or die("sql_del: ".mysql_error($connect));

$connect1 = connect_to_db("con.inc");
$query1 = "SELECT * FROM [b]purc_item[/b] WHERE
ID='{$_SESSION['ID']}'";
$result1 = mysql_query($query,$connect1)
or die("sql_del: ".mysql_error($connect1));

The only difference is the table which is highlighted in bold and i have changed the variable names. Now the following code is used to extract the data:

echo "The ID for the product is: <br>";

while($row = mysql_fetch_array($result))
{
echo ''.$row['ID'].'';
}

echo "The quantity for the product is: <br>";

while($row = mysql_fetch_array([b]$result1[/b]))
{
echo "<td><b>";
echo ''.$row['quantity'].'';
echo "</b></td>";
}
echo "<br><br>";

The first piece of data is extracted perfectly but the second piece doesnt seem to work?? I have changed the variable name. It seems i can keep extracting data from the first query but not the second? I had this problem before and wanst able to see what i was doing wrong?
Link to comment
https://forums.phpfreaks.com/topic/7536-one-query-works-but-the-other-doesnt/
Share on other sites

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.