Re: Variable won't work in function, even when I global it?

From: Date: Mon, 20 May 2002 06:12:54 +0000
Subject: Re: Variable won't work in function, even when I global it?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98429@lists.php.net to get a copy of this message
No good as in "that doesn't solve it" or as in "I sure wish it didn't have to be that way"? miguel On Mon, 20 May 2002, Leif K-Brooks wrote: > No good. :-( > > Miguel Cruz wrote: > > >Okay, I'm pretty sure your problem is this: > > > >All those variables referenced in $footertext ($REMOTE_ADDR, $userinfo, > >etc.) need to be brought into the local context in the function calling > >eval(), using the global keyword. Otherwise they won't be available. > > > >miguel > > > >On Mon, 20 May 2002, Leif K-Brooks wrote: > > > >>Ok, I guess I'll send it. Thanks for trying to help. Here it is: > >> > >> $ip = $REMOTE_ADDR; > >> $query = mysql_query("select COUNT(*) as rowexists from ips where ip > >> = '$ip'"); > >> $result = mysql_fetch_array($query); > >> if(($result['rowexists'] == 0) && ($loggedin)){ > >> mysql_query("INSERT INTO ips (ip,username) > >> VALUES > >> ('$ip','$userinfo[username]')") or print "Error: > >> ".mysql_error(); > >> } > >> $time_end = getmicrotime(); > >> $time_taken = $time_end - $time_start; > >> $query = mysql_query("select COUNT(*) as cnt from ips"); > >> $result = mysql_fetch_array($query); > >> $visits = $result['cnt'] + 2800; > >> eval($getlayout['footer']); > >> > >> > >>Miguel Cruz wrote: > >> > >>>Rather than continuing to shroud this in mystery, could you at least give > >>>us a taste of what is in $footertext? > >>> > > > > > >

« previous php.general (#98429) next »