Re: Re: catch the error

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

 



PJ you should be getting Warning errors the way you had the code.

You definitely is a fun lover and enjoy moments. But while coding dont only
think of fastness of coding but also code with logic.

I was going to answer you about the $db but later I found lots response
already came so didn't really dig to get the errors. Look back, see, I asked
if you got rid of the errors :)

Now, if you dont use the  variable in the parameter it will look for the
immediate opened database resource but if you use a variable..... THEN it
must contain that required resource thats just OBVIOUS reason. And, your
error reporting should be reporting that. I haven't checked the code. A
funny thing is you are making others think for the things you should be
thinking. I dont say its bad. Its actually good for all of us having some
drill on the basics :D

Regards

Lenin

www.twitter.com/nine_L
www.lenin9l.wordpress.com

On Fri, Feb 27, 2009 at 6:37 AM, Chris <dmagick@xxxxxxxxx> wrote:

> Boyd, Todd M. wrote:
>
>> -----Original Message-----
>>> From: Chris [mailto:dmagick@xxxxxxxxx]
>>> Sent: Thursday, February 26, 2009 4:16 PM
>>> To: Boyd, Todd M.
>>> Cc: PJ; PHP General list
>>> Subject: Re:  Re: catch the error
>>>
>>>
>>>  In examples sent to you, people foolishly replaced your $db var with
>>>> $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your
>>>>
>>> database
>>
>>> connection as $db_connect in some versions of the source, but then
>>>>
>>> you
>>>
>>>> reference $db (without _connect) in your mysql_select call in that
>>>>
>>> same
>>>
>>>> source.
>>>>
>>>> $db = mysql_connect([option list here]); # <-- this code
>>>>
>>> instantiates
>>
>>> a
>>>
>>>> connection
>>>> 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. That
>>>>
>>> resource
>>>
>>>> link must then be passed to your mysql functions. Otherwise, they
>>>>
>>> have
>>>
>>>> no 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 have
>>>
>> multiple
>>
>>> connections 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.
>>
>
> The last two emails I saw (no I haven't read the whole thread) were:
>
> >> $db = mysql_connect($db_host, $db_user, $db_pass);
> >> > >> mysql_select_db($db_name,$db);
>
> <snip>
>
> >> > >> $result1 = mysql_query($sql1,$db);
>
> and
>
> > $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/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux