koolgirl Posted June 6, 2006 Share Posted June 6, 2006 first of all Thanks kenrbnsn & poirotkenrbnsn, 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 appreciatedMany Thanks Quote Link to comment https://forums.phpfreaks.com/topic/11326-thanks-kenrbnsn-one-more-question-users-host/ Share on other sites More sharing options...
obsidian Posted June 6, 2006 Share Posted June 6, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/11326-thanks-kenrbnsn-one-more-question-users-host/#findComment-42409 Share on other sites More sharing options...
koolgirl Posted June 6, 2006 Author Share Posted June 6, 2006 THANKSSSSSSSSS obsidianP_E_R_F_E_C_T_L_Y working nowThanks again! Quote Link to comment https://forums.phpfreaks.com/topic/11326-thanks-kenrbnsn-one-more-question-users-host/#findComment-42414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.