Re: [Fwd: Re: Please stop me from tearing my hair out.]

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

 



On Thu, 2008-06-19 at 12:33 +0100, Richard Heyes wrote:
> Fowarded message.
> 
> email message attachment (Re:  Please stop me from tearing my
> hair out..eml)
> > -------- Forwarded Message --------
> > From: Byron <klingemeister@xxxxxxxxx>
> > To: richardh@xxxxxxxxxxx
> > Subject: Re:  Please stop me from tearing my hair out.
> > Date: Thu, 19 Jun 2008 22:47:48 +1200
> > 
> > now it says this? Parse error: syntax error, unexpected '=',
> > expecting ',' or ';' in C:\wamp\www\achillesweb2\functions.php on
> > line 14
> > ?.?
> > 
> > On Thu, Jun 19, 2008 at 10:45 PM, Byron <klingemeister@xxxxxxxxx>
> > wrote:
> >         okay, so i got static and global mixed up? Thanks.
> >         
> >         
> >         
> >         On Thu, Jun 19, 2008 at 10:44 PM, Richard Heyes
> >         <richardh@xxxxxxxxxxx> wrote:
> >                 Byron wrote:
> >                         right.
> >                         
> >                         Now I'm getting the following errors after
> >                         doing a semi-colon triple check.
> >                         
> >                         
> >                         *Warning*: mysql_select_db(): supplied
> >                         argument is not a valid MySQL-Link resource
> >                         in *C:\wamp\www\achillesweb2\functions.php*
> >                         on line *48*
> >                 
> >                 $con Is not accessible (because you're in a function
> >                 when you create it).

Ummm, yes it is :) Static variables have persistence beyond the function
call and thus beyond the function scope itself.

> >                  ie. When you create it (ie when you connect to
> >                 MySQL) you could stick it in the global scope. ie In
> >                 your connection function, make this the first
> >                 statement:
> >                 
> >                 global $con;

Yes, you could do that... but ad-hoc shoving stuff into global space is
poor style.

> >                 Then you can do the same in other functions, or
> >                 alternatively you can access it like so:
> >                 
> >                 $GLOBALS['con']

Not that I like the current implementation, I merely followed what he
was aiming for, but the implementation above works fine in practice (not
withstanding any syntax bugs I may have left since it's untested).

Cheers,
Rob.

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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