Re: Re: catch the error
| From: | Chris | Date: | Fri, 27 Feb 2009 00:37:54 +0000 |
| Subject: | Re: Re: catch the error | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288892@lists.php.net to get a copy of this message | ||
Boyd, Todd M. wrote:
The last two emails I saw (no I haven't read the whole thread) were:-----Original Message----- From: Chris [mailto:dmagick@gmail.com] Sent: Thursday, February 26, 2009 4:16 PM To: Boyd, Todd M. Cc: PJ; PHP General list Subject: Re: [PHP] Re: catch the errordatabaseIn examples sent to you, people foolishly replaced your $db var with $db_connect ONLY FOR PART OF THE SCRIPT. You've defined yourinstantiatesconnection as $db_connect in some versions of the source, but thenyoureference $db (without _connect) in your mysql_select call in thatsamesource. $db = mysql_connect([option list here]); # <-- this codeamultipleconnection mysql_select_db([some name], $db); # notice how $db is here? $result = mysql_query([some query], $db); # it's here, too! $db becomes your resource link when you use mysql_connect. Thatresourcelink must then be passed to your mysql functions. Otherwise, theyhaveno idea which database connection you are attempting to use.RTFM? If no connection is specified, the last one is used. It is an optional argument (only *really* needed when you haveconnections in the same script).RTF E-mail I sent? He had used $db_connect instead of $db. $db_connect hadn't been set to anything. He was specifying a connection, but it was null. Unless it falls back to the last connection used in the case of an empty variable, then this was most likely (read: proven to be) the problem.
<snip>$db = mysql_connect($db_host, $db_user, $db_pass);mysql_select_db($db_name,$db);
and$result1 = mysql_query($sql1,$db);
$db = mysql_connect($db_host, $db_user, $db_pass); mysql_select_db($db_name,$db);which have the right variables. Plus I was picking on the "you must do this" - using the link identifier is an optional thing as I already said. -- Postgresql & php tutorials http://www.designmagick.com/