andrew_ww Posted December 28, 2006 Share Posted December 28, 2006 Hello,I have attached some code which when its working is suppose to log various things when a user visits the site (IP, etc..) This script runs without giving an errors, but it does not update anything to database. When I try to output what its captured the only thng it tells me that I'm localhost.Does anything look out of place with it ?-----------------------------<?phpsession_start();$conn = mysql_connect("localhost", "your-db-login-name", "your-db-password") or die(mysql_error());mysql_select_db("DATABASE-NAME", $conn) or die(mysql_error());$sql0 = "select session from getinfo order by id DESC LIMIT 1";$rslt = mysql_query($sql0) or print("The query: <B>" . $sql . "</B> gave the error <B>" . mysql_error() . "</B>");if (mysql_num_rows == 1) { $session = mysql_result($rslt, 0, 'session'); if (session_id() != $session) { $sql = "insert into getinfo values('', '$_SERVER[REMOTE_ADDR]','".gethostbyaddr($_SERVER[REMOTE_ADDR])."', '$_SERVER[HTTP_REFERER]', now(), '".session_id()."')"; $query = mysql_query($sql) or print("The query: <B>" . $sql . "</B> gave the error <B>" . mysql_error() . "</B>"); } } else { $sql = "insert into getinfo values('', '$_SERVER[REMOTE_ADDR]','".gethostbyaddr($_SERVER[REMOTE_ADDR])."', '$_SERVER[HTTP_REFERER]', now(), '".session_id()."')"; $query = mysql_query($sql);}$display_block .="< p>You are visitor number $users.< p>You are visiting from $host< p>Your IP address is: $ip";?>----------------------------------------------------------Thanks,Andy.[attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
onlyican Posted December 28, 2006 Share Posted December 28, 2006 From your code snippit I would like to look at the bottom part[code]<?php$display_block .="< p>You are visitor number $users.< p>You are visiting from $host< p>Your IP address is: $ip";?>[/code]I can not see in your script, where you are naming these vars Quote Link to comment Share on other sites More sharing options...
taith Posted December 28, 2006 Share Posted December 28, 2006 mysql_num_rows is a function... not a defined word...[code]if(mysql_num_rows($rslt) == 1){[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.