simcoweb Posted October 4, 2006 Share Posted October 4, 2006 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><tdbgcolor=\"#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? :) Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/ Share on other sites More sharing options...
trq Posted October 4, 2006 Share Posted October 4, 2006 Im sorry, but whatever editor your using is making your code impossible to read, but generally, that error meens your query failed. try checking it for success before attempting to use its results. Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103770 Share on other sites More sharing options...
simcoweb Posted October 4, 2006 Author Share Posted October 4, 2006 Sorry about that. I didn't preview the post first. Not sure why the code all freaked out. Anyway, I fixed it so it's readable now.Ok, i'll check the query for success and post back. Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103776 Share on other sites More sharing options...
trq Posted October 4, 2006 Share Posted October 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103778 Share on other sites More sharing options...
kenrbnsn Posted October 4, 2006 Share Posted October 4, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103779 Share on other sites More sharing options...
simcoweb Posted October 4, 2006 Author Share Posted October 4, 2006 Ok, that produced this:[quote] Problem is this:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103787 Share on other sites More sharing options...
trq Posted October 4, 2006 Share Posted October 4, 2006 Your problem is probably the fact that your using the variable $SESSION in your query. Unless you created this yourself, the global is $_SESSION. Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103825 Share on other sites More sharing options...
.josh Posted October 4, 2006 Share Posted October 4, 2006 also you need quotes around the data in your query. try it this way:[code]$sql4 = "SELECT * FROM plateau_pros WHERE username='{$_SESSION['username']}'";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22983-why-is-this-returning-not-valid-resource-error/#findComment-103838 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.