Jump to content


Thanks kenrbnsn, one more question user's host

  • Please log in to reply
2 replies to this topic

#1 koolgirl

  • Members
  • PipPip
  • Member
  • 17 posts

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


"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

#2 obsidian

  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 06 June 2006 - 01:48 PM

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='" . 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:

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

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

hope this helps!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 koolgirl

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 June 2006 - 02:05 PM


P_E_R_F_E_C_T_L_Y working now

Thanks again!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users