entity azirius Posted May 29, 2006 Share Posted May 29, 2006 Today I am taking my first steps into using MySQL and I have had a lot of problems with it.Userlist.php <?php$con = mysql_connect("localhost","VALID USER","VALID PASS");if (!$con) { die('Could not connect: ' . mysql_error());}mysql_select_db("VALID DB", $con);$result = mysql_query("SELECT * FROM user");while($row = mysql_fetch_array($result)) { echo $row['username']; echo "<br />"; echo $row['email']; echo "<br />"; echo $row['registration_date']; echo "<br />"; echo $row['user_id']; echo "<br />";}?> I've finally got to my last piece of coding, but an error keeps being proccessed: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/entitys/public_html/scripttest/userlist.php on line 12Now apparently what I've scrippted is wrong, but according to this My code looks correct to me. If someone could help me with my problems then I'd be majorly greatful.Regards, entity azirius. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2006 Share Posted May 29, 2006 I assume you aren't actually using this code:$con = mysql_connect("localhost","VALID USER","VALID PASS");if (!$con) { die('Could not connect: ' . mysql_error());}mysql_select_db("VALID DB", $con);Instead of "VALID USER", "VALID PASS", and "VALID DB", I assume you are using the correct information.Make sure you have a table called "user" in the database. If you still aren't sure, use the mysql_error() function to see what the error is. <?php$con = mysql_connect("localhost","VALID USER","VALID PASS");if (!$con) { die('Could not connect: ' . mysql_error());}mysql_select_db("VALID DB", $con);$result = mysql_query("SELECT * FROM user");echo mysql_error($con);?> Link to comment Share on other sites More sharing options...
entity azirius Posted May 29, 2006 Author Share Posted May 29, 2006 You asssume correct, I just didn't wanna give away my conection details. Well it seems to have sorted itself out now. Thank you very much for your help, you gave me a bit of extra information as well! Thank you! 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