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? :)
Link to comment
Share on other sites

Also... please use the [ php ] [ / php ] tags. Much easier on the eye.

ps; Your problem is probably the fact that your using the variable $SESSION in your query. Unless you created this yourself, the global is $_SESSION.
Link to comment
Share on other sites

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
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.