Jump to content

Why is this returning 'Not Valid Resource' error?


simcoweb

Recommended Posts

I'm confused since I have several working scripts using identical code. But for some reason I can't see why this setup is a problem:

[code]<?php
$sql4 = "SELECT * FROM plateau_pros WHERE username=".$SESSION['username'].""; $results4 = mysql_query($sql4);

while ($row4 = mysql_fetch_array($results4)) { echo "<table width\"500\" border=\"0\"> <tr><td
bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Name: </b></td> <td bgcolor=\"#e0e0e0\"><class=\"bodytext\">". $row4['firstname'] ." " .$row4['lastname'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Business: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">testing testing testing ". $row4['business'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Title: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['title'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Phone: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['phone'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Mobile:</b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['mobile'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Fax: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['fax'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Email: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['email'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>URL: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['url'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Details: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['details'] ."</td></tr>
<tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Specialties: </b></td>
<td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['specialties'] ."</td></tr> </table>\n";
}
?>
[/code]

This returns this error:

[quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/members-view.php on line 271[/quote]

Guidance? :)
Replace this line:
[code]<?php $results4 = mysql_query($sql4); ?>[/code]
with
[code]<?php $results4 = mysql_query($sql4) or die("Problem with the query: $sql4<br>" . mysql_error()); ?>[/code]

This will tell you what's wrong with your query.

Ken

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.