Jump to content


PHP Debug Help


  • Please log in to reply
1 reply to this topic

#1 Guest_$$$-scorpion-$$$_*

Guest_$$$-scorpion-$$$_*
  • Guests

Posted 03 July 2006 - 10:18 AM

Hi Guys.
Need help debugging my first PHP script to log a user ip address browser etc
Code Below For

logger.php
<?
include 'config.php' ;
function LogIp()
{
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("l dS of F Y h:i:s A"; 
$browser = $_SERVER['HTTP_USER_AGENT'];
$referer = $_SERVER['HTTP_REFERER'];
$insert = "INSERT into logger 
	(ip, date, browser, referer)
		VALUES ('$ip' , '$browser' , '$referer')";
		$logquerry = mysqli_query($connect, $insert);
		}
LogIp()
?>

and config.php

<?
$host = localhost ;
$user = root ; 
$pass = password ;
$db = databaste ;
$connect = mysqli_connect('$host' , '$user' , '$pass' , '$db') ;
?>

thanks in advance for your help

BTW im only 14 so sorry for any spelling mistakes

#2 Houdini

Houdini
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 03 July 2006 - 01:14 PM

Change the config.php to this
<?
$host = "localhost" ;
$user = "root" ; 
$pass = "password" ;
$db = "databaste" ;
$connect = mysqli_connect($host , $user , $pass , $db) ;
?>
And you might want to add some error checking here
$logquerry = mysqli_query($connect, $insert);
change to this
$logquerry = mysqli_query($connect, $insert)
  or die("Could not execute the query! MySQL said: ".mysql_error());

We the unwilling, led by the unknowing,
have done so much, for so long, with so little,
that we are now quqlified to do anything, with nothing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users