Page 1 of 1
the corect sintax
Posted: Sat May 14, 2011 12:50 pm
by ta2shop
hy guys, i am playng with the browser identification thing, and i want to add some data to a DB, but a dont want to define everi thing in a new $var haw can i add the values in using just the $_POST['thing']; thing?
thanks.
$query = mysql_query("INSERT INTO brovsers VALUES('','$_POST['1']','$_POST['2']','$_POST['2']')") or die(mysql_error());
Re: the corect sintax
Posted: Sat May 14, 2011 12:53 pm
by jacek
Easiest way is to wrap them in {} like this ...
$query = mysql_query("INSERT INTO brovsers VALUES('','{$_POST['1']}','{$_POST['2']}','{$_POST['2']}')") OR die(mysql_error());
Bare in mine though that these variables need to be escaped
Re: the corect sintax
Posted: Sat May 14, 2011 1:00 pm
by ta2shop
jacek wrote:Easiest way is to wrap them in {} like this ...
$query = mysql_query("INSERT INTO brovsers VALUES('','{$_POST['1']}','{$_POST['2']}','{$_POST['2']}')") OR die(mysql_error());
Bare in mine though that these variables need to be escaped
like so?
$query = mysql_query("INSERT INTO brovsers VALUES('','{$_POST['\1\']}','{$_POST['\2\']}','{$_POST['\2\']}')") OR die(mysql_error())
Re: the corect sintax
Posted: Sat May 14, 2011 1:01 pm
by jacek
There is no need for the \ but yeah pretty much like that.
Re: the corect sintax
Posted: Sat May 14, 2011 1:06 pm
by ta2shop
ok, now i get it, one last thing, i now that to add the ip i need to do this $_SERVER['REMOTE_ADDR']; but how can i add the date(); thing to this query?
thanks
EDIT* all done, fixed.