Hi,
I been having allot of help on here certainly from 'Josh Connerty', who has done a fantastic job of helping me. I am learning php and am enjoying it.
So before i start a big thanks to Josh Connerty and this forum existing as it is a pleasure to be part of a great helpful community.
Ok, back to where i need help.
I basically need to create a MySQL table and fields within the table.
I don't want to create it using php just so i can go to PHPMyAdmin and in the SQL query box enter in the info and let PHPMyAdmin create it that way.
I am having difficulty in knowing what type to use for each field,
I basically need 8 fields in the table. These 8 fields are going to store data about users. I only need one table.
Below is my code, if someone could read it and if they would be kind enough to create me the MySQL info that i need to enter into PHPMyAdmin to create the table.
Things that confuse are things such as the referral url, as if someone was referred from another website where the website that referred them had a very long url which type would be best to use such as CHAR, Text etc... due to possible lenght of url,
I would value and appreciate your time if someone could help.
Thank you,
genieuk
<?php
include("dbconnect.php");
// Change this to however many days until you need to add a new version. Defaults to 31 or a month.
$days = 1;
$ip = $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($ip);
$agent = $_SERVER['HTTP_USER_AGENT'];
$uri = $_SERVER['REQUEST_URI'];
$ref = $_SERVER['HTTP_REFERER'];
$oslang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
if($ip == ""){
$ip = "None Recorded";
}
if($host == ""){
$host = "None Recorded";
}
if($agent == ""){
$agent = "None Recorded";
}
if($uri == ""){
$uri = "None Recorded";
}
if($ref == ""){
$ref = "None Recorded";
}
if($oslang == ""){
$oslang = "None Recorded";
}
while( $use == false ) {
$temp = rand( 100000000 , 999999999 );
$t = mysql_query("SELECT * FROM visitordata WHERE id='$temp'");
if( @mysql_num_rows( $t ) > 0 ) {
return false;
} else {
$id = $temp;
$use = true;
}
}
$length = 60*60*24*$days;
$time = time() + $length;
$test = mysql_query("SELECT * FROM visitordata WHERE ip='$ip'");
if( @mysql_num_rows( $test ) == 0 ) {
$query = "INSERT INTO visitordata VALUES ('$id', '$time', '$ip', '$host', '$agent', '$uri', '$ref', '$oslang')"; //*visitordata is the name of the MySQL table where the user data will be saved.
mysql_query( $query ) or die( "MySql Error Occured: " . mysql_error() );
echo "The user data was successfully added to your database.";
} else {
$row = mysql_fetch_array( $test );
if( $row['dbtime'] <= time() ) {
$query = "INSERT INTO visitordata VALUES ('$id', '$time', '$ip', '$host', '$agent', '$uri', '$ref', '$oslang')"; //*visitordata is the name of the MySQL table where the user data will be saved.
mysql_query( $query ) or die( "MySql Error Occured: " . mysql_error() );
echo "The user data was successfully added to your database.";
}
}
mysql_close($conn);
?>
I know i need to start off with
CREATE TABLE visitordata
but that's all lol ... is someone could help me finish it off please.