I use a header file for my database take this code and save it as database.php
<?PHP
if(!function_exists('connect'))
{
function connect()
{
$mysql_host = "localhost";
$mysql_user = "your_username";
$mysql_pass = "your_password";
if(! $linkid = mysql_connect("$mysql_host" , "$mysql_user",
"$mysql_pass"))
{
echo "Error connecting to ".$mysql_host;
exit;
}
return $linkid;
}
}
if(!function_exists('send_sql'))
{
function send_sql($sql, $link, $db) {
if(!($succ = mysql_select_db($db))) {
echo mysql_error();
exit;
}
if(!($res = mysql_query($sql, $link))) {
echo mysql_error();
exit;
}
return $res;
}
}
?>
Then just enter the server the username and password to access the database
Then in your code just include the database.php and use its methods like this
<?php
include("database.php");
$link = connect();
$db = "techbiz_trade";
$sql="INSERT INTO yourdatabase.yourtable(ip_address)
VALUES
('$ip_address')";
send_sql($sql, $link, $db);
?>
That should insert it for you. Oh and make sure you use escape_string on the ip address like this for security
<?php
$ip_address = mysql_escape_string($_SERVER['REMOTE_ADDR']);
?>