More help with mysql
| From: | (Evan Morris) | Date: | Tue, 18 Feb 2003 07:51:09 +0000 |
| Subject: | More help with mysql | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25713@lists.php.net to get a copy of this message | ||
Hi all
I have successfully managed to connect to the mysql database, using the
following code:
mysql_connect('localhost','php','*******') || die ("Unable to
connect to
MySQL server.");
$db = mysql_select_db("DB_NAME") || die ("Unable to select requested
database.");
I then issue the following command:
$result = mysql_query("SELECT * FROM SOME_TABLE") || die(mysql_error());
This does not result in any error.
Now, of course, I want to work with the data returned, so I go:
if (mysql_num_rows($result) > 0)
{
// do some stuff
}
else
{
// do some other stuff
};
However, this gives me: "Supplied argument is not a valid MySQL result
resource."
If I go: echo "$result", I get '1', so I know $result actually has some
value.
What am I doing wrong? Basically, I want to do the simplest thing: get data
out of a table and step through the results, displaying them one by one. Why
is this hard?
Evan Morris
evan@exclusivebooks.com
Tel: +27 11 792 2777
Fax: +27 11 792 2711
Cell: +27 82 926 3630