Re: PHP4 and MySQL

From: Date: Thu, 26 Oct 2000 11:08:39 +0000
Subject: Re: PHP4 and MySQL
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-3936@lists.php.net to get a copy of this message
Anzej Becan wrote: > > > I'm new to this list, and it might have been asked before (sorry). > > I have following problem: > > When I have PHP code like this: > > $rs_result=mysql_db_query($db,"SELECT * FROM XX WHERE > > something=$yy",$connection); > > while($row_result=mysql_fetch_array($rs_result)) > > { do_something(); } > > I think you should use this: > - - - - - > $dbh=mysql_connect($host,$username,$password) or mysql_die(); > $rs_result=mysql_db_query($db,"select ..."); > while... > - - - - - > The wrong thing is $connection at the end of line 2. No, it is not wrong. This porticular script connects to to diffrent SQL Servers - thus the third paramenter in the mysql_db_query function is required. I just included 3 lines in my prevois email it to describe the problem. I know I have to connect to the server first. The problem is the mysql_fetch_array($rs_result) function. It throws a warning if $rs_result contains no rows. Thanks anyway, Robert

« previous php.db (#3936) next »