Jump to content

Archived

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

Guest $$$-scorpion-$$$

PHP Debug Help

Recommended Posts

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

logger.php
[code]<?
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()
?> [/code]

and config.php

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

thanks in advance for your help

BTW im only 14 so sorry for any spelling mistakes

Share this post


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

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.