Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

INSERT INTO - problem!? please help

Codes here !

Moderators: macek, egami, gesf

INSERT INTO - problem!? please help

Postby php-punk » Sun Feb 02, 2003 3:28 am

Right i have made this code for a stats page, so it will collect the user Ip and stuff, but i have a problem when running the srip i get a parse eror on the INSERT line or the query line, can anyone tell me whats wrong !?


[code]<?
//getting the user's IP address
$Rip=$_SERVER['REMOTE_ADDR'];
//getting the user's Port
$Rport=$_SERVER['REMOTE_PORT'];


//Getting the user's Browser (Agent)
$b=$_SERVER['HTTP_USER_AGENT'];

//getting the referries URL
$r=$_SERVER['HTTP_REFERER'];

//Put all this into a Database for later viewing:


//connect to the DB
$Connect=mysql_connect(localhost,userr,pw);

//select DB
$DB=mysql_select_db(stu3sk8r_uk_db);

//setting the query in a variable, the query, in this case it
//INSERTS to the db

$query="INSERT INTO cstats ('ip','port','browser','reffer','date') VALUES ('$Rip','$Rport','$b','$r','');

//running the actual query
mysql_query($query)

?>[/code]
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Oleg Butuzov » Sun Feb 02, 2003 4:58 am

$query="INSERT INTO cstats (`ip`,`port`,`browser`,`reffer`,`date`) VALUES ('$Rip','$Rport','$b','$r','');
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Parse Error

Postby Mixamajic » Sun Feb 02, 2003 7:07 pm

Try this,

$query="INSERT INTO cstats VALUES ('$Rip','$Rport','$b','$r', NULL)";

Your example recieved a parse error because of the placement of the quotes. You were recieving a PHP error, not a mysql error. You will also need a semi-colon after the mysql_query.
Mixamajic
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Feb 02, 2003 6:54 pm
Location: Milwaukee


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron