Re: Variable won't work in function, even when I global it?
| From: | Leif K-Brooks | Date: | Mon, 20 May 2002 06:09:51 +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-98428@lists.php.net to get a copy of this message | ||
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 INTOips(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?