Jump to content

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource


chrishawkins

Recommended Posts

I am getting this error; Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

 

running this code;

 

<form name="form1" method="post" action="">
<label>
<input type="submit" name="update" id="update" value="Update Records">
</label>
</form>
<form name="form2" method="get" action="test.php?show_record=1">
<label>
<input type="submit" name="show_results" id="show_results" value="Show Results">
</label>
</form>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

if(isset($_GET['show_results']) && $_GET['show_results'] == 1){
$res = mysql_query("SELECT *, probid_users.name AS name,
probid_winners.winner_id AS winnerid
FROM probid_winners
left join probid_users ON probid_users.user_id = probid_winners.buyer_id
WHERE probid_winners.payment_status='confirmed' AND printed='' AND buyer_id BETWEEN 2 AND 1000000000 ORDER BY bid_amount DESC = " . mysql_real_escape_string($_GET['show_results']));
}

echo "<table border='5'>
<tr>
<th>Name</th>
<th>Auction ID</th>
<th>Bid Amount</th>
<th>Deposit Status</th>
</tr>";

while($row = mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['auction_id'] . "</td>";
echo "<td>" . $row['bid_amount'] . "</td>";
echo "<td>" . $row['payment_status'] . "</td>";
echo "<td><form1=\"update_row\" method=\"post\" action=\"test.php?id=".$row['winnerid']."\">
<input type=\"hidden\" name=\"updating_row\" value=\"".$row['winnerid']."\" />
<input type=\"submit\" name=\"submit_update\" value=\"Remove\" />
</form>";
echo "</tr>";

if(isset($_POST['updating_row'])){
$res = mysql_query("UPDATE probid_winners SET printed='printed' WHERE probid_winners.winner_id = " . mysql_real_escape_string($_POST['updating_row']));
}
}
echo "</table>";

mysql_close($con);
?> 

 

I was hoping that someone might be able to help me out with this issue.

Updated:

 

Is this what you mean;

 

<form name="form1" method="post" action="">
<label>
<input type="submit" name="update" id="update" value="Update Records">
</label>
</form>
<form name="form2" method="get" action="test.php?show_results=1">
<label>
<input type="submit" name="show_results" id="show_results" value="Show Results">
</label>
</form>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

if(isset($_GET['show_results']) && $_GET['show_results'] == 1){
$res = mysql_query("SELECT *, probid_users.name AS name,
probid_winners.winner_id AS winnerid
FROM probid_winners
left join probid_users ON probid_users.user_id = probid_winners.buyer_id
WHERE probid_winners.payment_status='confirmed' AND printed='' AND buyer_id BETWEEN 2 AND 1000000000 ORDER BY bid_amount DESC = " . mysql_real_escape_string($_GET['show_results'] or trigger_error (mysql_error());
}

echo "<table border='5'>
<tr>
<th>Name</th>
<th>Auction ID</th>
<th>Bid Amount</th>
<th>Deposit Status</th>
</tr>";

while($row = mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['auction_id'] . "</td>";
echo "<td>" . $row['bid_amount'] . "</td>";
echo "<td>" . $row['payment_status'] . "</td>";
echo "<td><form1=\"update_row\" method=\"post\" action=\"test.php?id=".$row['winnerid']."\">
<input type=\"hidden\" name=\"updating_row\" value=\"".$row['winnerid']."\" />
<input type=\"submit\" name=\"submit_update\" value=\"Remove\" />
</form>";
echo "</tr>";

if(isset($_POST['updating_row'])){
$res = mysql_query("UPDATE probid_winners SET printed='printed' WHERE probid_winners.winner_id = " . mysql_real_escape_string($_POST['updating_row'] or trigger_error (mysql_error());
}
}
echo "</table>";

mysql_close($con);
?>

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.