Re: [Fwd: Re: [PHP] Please stop me from tearing my hair out.]
| From: | Robert Cummings | Date: | Thu, 19 Jun 2008 14:54:24 +0000 |
| Subject: | Re: [Fwd: Re: [PHP] Please stop me from tearing my hair out.] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275599@lists.php.net to get a copy of this message | ||
On Thu, 2008-06-19 at 12:33 +0100, Richard Heyes wrote:
> Fowarded message.
>
> email message attachment (Re: [PHP] Please stop me from tearing my
> hair out..eml)
> > -------- Forwarded Message --------
> > From: Byron <klingemeister@gmail.com>
> > To: richardh@phpguru.org
> > Subject: Re: [PHP] 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@gmail.com>
> > wrote:
> > okay, so i got static and global mixed up? Thanks.
> >
> >
> >
> > On Thu, Jun 19, 2008 at 10:44 PM, Richard Heyes
> > <richardh@phpguru.org> 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