Jump to content

Thanks kenrbnsn, one more question user's host


koolgirl

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:

<?php

$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:

<?php

$dbcnx = @mysql_connect(

'mysql','username','mypass');

mysql_select_db("Main");

$sql = "INSERT INTO Records SET " .

"IP='$REMOTE_ADDR', " .

"BrowserName='$HTTP_USER_AGENT', " .

"Language='$HTTP_ACCEPT_LANGUAGE', " .

"Referer='$HTTP_REFERER', " .

"Date=NOW()";

______________________________________________________

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
Link to comment
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';
[!--sql2--][/div][!--sql3--]

now, if you're simply adding a column to the insert statement, just do something like this, and you should be golden:
[code]
<?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']) . "')";
[/code]

hope this helps!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.