duncan_cowan Posted November 4, 2006 Share Posted November 4, 2006 Hi please could someone tell me what is wrong with this code: <?phpinclude("db_connect.php");$query = mysql_query("SELECT * FROM armies WHERE username=".$_SESSION['username']."");while($row = mysql_fetch_array($query)) { }?> When i run it it says:"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/i04wasp/public_html/protected/armyhome.php on line 10"Thankyou... Link to comment Share on other sites More sharing options...
skym Posted November 4, 2006 Share Posted November 4, 2006 Most probably an SQL error. Use$query = mysql_query("SELECT * FROM armies WHERE username=".$_SESSION['username']."") or die('SQL error: '.mysql_error());to see what the error is. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 6, 2006 Share Posted November 6, 2006 You probably left out the quotes around the username: $query = mysql_query("SELECT * FROM armies WHERE username='".$_SESSION['username']."'"); Link to comment Share on other sites More sharing options...
Guest nelly Posted November 8, 2006 Share Posted November 8, 2006 Change this:while($row = mysql_fetch_array($query))To this:while($row = @mysql_fetch_array($query)) Link to comment Share on other sites More sharing options...
yubaraj Posted November 8, 2006 Share Posted November 8, 2006 Your SQL Statement is wrong. You have left Quote in the sql command.For simplicity, do the following$ses_username = $_SESSION['username'];$query = mysql_query("select * from armies where username='$ses_username'"); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now