Jump to content

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


skidmark10

Recommended Posts

I've never encountered this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

 

Does anyone knows where it stems from, and ways to fix it?

 

Here's my code just in case.

 

$sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID=" .$_POST['clientid']. ""or die ('Error: '.mysql_error ());

$query = mysql_query($sql);

echo "<table border='0'>
<tr>
<th>Client ID</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
</tr>";

while ($row = mysql_fetch_array($sql));
   {
   echo "<tr>";
   echo "<td>" . $row['Client_ID'] . "</td>";
   echo "<td>" . $row['Slim_Slender'] . "</td>";
   echo "<td>" . $row['Average'] . "</td>";
   echo "<td>" . $row['Athletic'] . "</td>";
   echo "<td>" . $row['Heavy'] . "</td>";
   echo "</tr>";
   }
echo "</table>";

mysql_close($con);
?> 

Link to comment
Share on other sites

please mark as solved. the topic solved button can be found at the bottom left of the page

 

I am still receiving the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource after making the corrections. Is there anything else I can do?

 

$sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID= " .$_POST['clientid']. "";

$query = mysql_query($sql);

echo "<table border='0'>
<tr>
<th>Client ID</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
<th>Partner's Body Type</th>
</tr>";

while ($row = mysql_fetch_array($query))
   {
   echo "<tr>";
   echo "<td>" . $row['Client_ID'] . "</td>";
   echo "<td>" . $row['Slim_Slender'] . "</td>";
   echo "<td>" . $row['Average'] . "</td>";
   echo "<td>" . $row['Athletic'] . "</td>";
   echo "<td>" . $row['Heavy'] . "</td>";
   echo "</tr>";
   }
echo "</table>";

mysql_close($con);
?> 

Link to comment
Share on other sites

The query is failing for some reason, but you have no error-handling logic in place to catch that and report any errors. Is that all of the code, or is there more to it?

 

How can I put in the error-handling logic? :)

This is all of my php code (minus my database connection code), I'll post my html code so you can see the form.

 

HTML

<form name="input" action="fetchclientprofile.php" method="GET">
<center> Client ID <input type="text" name="clientid" /><br /> </center>
<center> <input type="submit" value="Retrieve" /> </center>

 

PHP

$sql = "SELECT * FROM `Partners_Body_Types` WHERE Client_ID= " .$_POST['clientid']. "";

 

$query = mysql_query($sql);

 

echo "<table border='0'>

<tr>

<th>Client ID</th>

<th>Partner's Body Type</th>

<th>Partner's Body Type</th>

<th>Partner's Body Type</th>

<th>Partner's Body Type</th>

</tr>";

 

while ($row = mysql_fetch_array($query))

  {

  echo "<tr>";

  echo "<td>" . $row['Client_ID'] . "</td>";

  echo "<td>" . $row['Slim_Slender'] . "</td>";

  echo "<td>" . $row['Average'] . "</td>";

  echo "<td>" . $row['Athletic'] . "</td>";

  echo "<td>" . $row['Heavy'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

mysql_close($con);

?>

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.