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