Jump to content

mysql_fetch_array()


entity azirius

Recommended Posts

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 12
Now 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...