Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/13528-php-debug-help/
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]
Link to comment
https://forums.phpfreaks.com/topic/13528-php-debug-help/#findComment-52409
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.