Jump to content


This topic is now archived and is closed to further replies.


Thanks kenrbnsn, one more question user's host

Recommended Posts

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 " .


"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

Many Thanks

Share this post

Link to post
Share on other sites
well, for one thing, the syntax of the INSERT you are attempting is actually and UPDATE statement:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] Records SET userhost[color=orange]=[/color][color=red]'" . gethostbyaddr($_SERVER['[/color]REMOTE_ADDR[color=red]']) . "[/color][color=red]' [span style=\'color:green\']WHERE[/color] id [color=orange]=[/color] '[/span]$id';

now, if you're simply adding a column to the insert statement, just do something like this, and you should be golden:

$dbcnx = @mysql_connect('mysql','username','mypass');

$sql = "INSERT INTO Records (IP, BrowserName, Language, Referer, Date, userhost) " .

hope this helps!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.