Re: Warning: Supplied argument is not a valid MySQL result resource

From: Date: Wed, 30 Aug 2000 09:25:47 +0000
Subject: Re: Warning: Supplied argument is not a valid MySQL result resource
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14356@lists.php.net to get a copy of this message
manohar sadhasivam wrote:
Hi all, when i try to connect to Mysql server from the localhost, it says the above message.here is the piece of code. It says that the argument to mysql_num_rows $res is not a valid result. But it connects to the server and the table contains some data also. Please mail to my address, i am not in the list now. $res = mysql_db_query("company","select * from products"); $num = mysql_num_rows($res); echo"$num Records found<br>";
This is nasty code, but try this. I haven't tested it. Maybe it'll lead you in the right direction. <?php if(!$link = @mysql_pconnect($host, $user, $password)): print "Sorry, can't talk to MySQL."; elseif(!@mysql_select_db('company', $link)): print 'Unable to select your database. '; endif; if(!@mysql_query('SELECT * FROM products', $link)) print 'Query failed.'; ?>

« previous php.general (#14356) next »