Re: More help with mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 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]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux