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] Link to comment https://forums.phpfreaks.com/topic/32034-problem-with-code-thats-suppose-to-capture-user-information/ 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 Link to comment https://forums.phpfreaks.com/topic/32034-problem-with-code-thats-suppose-to-capture-user-information/#findComment-148691 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] Link to comment https://forums.phpfreaks.com/topic/32034-problem-with-code-thats-suppose-to-capture-user-information/#findComment-148733 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.