Thanks kenrbnsn, one more question user's host
Posted 06 June 2006 - 01:22 PM
first of all Thanks kenrbnsn & poirot
kenrbnsn, am using your tip. Working perfect but I got a little bit stuck in the next phase now. With the following script I do get the visitor's host address stored in the table but the next problem comes out when I want to store more information with the same script. For example this works fine:
$sql = "INSERT INTO Records SET IP='" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "'";
but how can I use this with my script because I am storing all info in the same table and I want to add one more field that is supposed to be the hostname. As I wrote yesterday also I am using doing it this way:
$dbcnx = @mysql_connect(
$sql = "INSERT INTO Records SET " .
"IP='$REMOTE_ADDR', " .
"BrowserName='$HTTP_USER_AGENT', " .
"Language='$HTTP_ACCEPT_LANGUAGE', " .
"Referer='$HTTP_REFERER', " .
now as kenrbnsn said, I want to add this line some how:
$sql = "INSERT INTO Records SET userhost='" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "'";
but still not working no matter how much I tried different ways. I know the solution will again be very simple but my knowledge is too low even for that. Any help will be very much appreciated
Posted 06 June 2006 - 01:48 PM
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] Records SET userhost='" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "' [span style=\'color:green\']WHERE id = '[/span]$id';
now, if you're simply adding a column to the insert statement, just do something like this, and you should be golden:
<?php $dbcnx = @mysql_connect('mysql','username','mypass'); mysql_select_db("Main"); $sql = "INSERT INTO Records (IP, BrowserName, Language, Referer, Date, userhost) " . "VALUES ('$REMOTE_ADDR', '$HTTP_USER_AGENT', '$HTTP_ACCEPT_LANGUAGE', '$HTTP_REFERER', NOW(), '" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "')";
hope this helps!
Posted 06 June 2006 - 02:05 PM
P_E_R_F_E_C_T_L_Y working now
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users