View Full Version : setting a variable from several $_GET's in the url
i have this
$pin = " . $_GET['first']; . " . $_GET['second']; . " . $_GET['third']; . " . $_GET['final']; . "
but it doesnt work, how do i set a variable from more than one $_GET part of the url or from several pieces of post data, so i can easily insert them into a db.
Dentafrice1
02-05-2007, 09:47 PM
Remove ; after every get
Heinous
03-05-2007, 06:04 AM
Change it to..
$pin = $_GET['first'] . $_GET['second'] . $_GET['third'] . $_GET['final'];
dont work this is what im trying to do
$query = mysql_query("INSERT INTO entrys (pin) VALUES('$_GET['first'] . $_GET['second'] . $_GET['third'] . $_GET['final'];')");
Drompo
03-05-2007, 04:04 PM
$first = "$_GET['first']";
$second = "$_GET['second']";
$third = "$_GET['third']";
$final = "$_GET['final]";
$pin = "$first $second $third $final";
mysql_query("INSERT INTO `entrys` (`pin`) VALUES ('$pin')") or die ("mysql_error()");
Try that
Drompo
03-05-2007, 07:48 PM
Tryed Mine?
Mentor
03-05-2007, 09:27 PM
Ok so on the assumption by the end of it the GET string after the file name is
?first=1&second=2&third=3&final=4
(the 1234 can be subsituted for any pin. Then in full
$pin = http_vars_get['first'].http_vars_get['second'].http_vars_get['third'].http_vars_get['final'] ;
mysql_query("INSERT INTO `entrys` (`pin`) VALUES ('$pin')") or die ("mysql_error()");
http_vars_get should not be used. Its totally outdated. You should use $_GET.
Ok so on the assumption by the end of it the GET string after the file name is
?first=1&second=2&third=3&final=4
(the 1234 can be subsituted for any pin. Then in full
$pin = http_vars_get['first'].http_vars_get['second'].http_vars_get['third'].http_vars_get['final'] ;
mysql_query("INSERT INTO `entrys` (`pin`) VALUES ('$pin')") or die ("mysql_error()");
Mentor
04-05-2007, 05:46 PM
http_vars_get should not be used. Its totally outdated. You should use $_GET.
Get doesnt seem to be working, hence its possible that his server could just be running an outdated php version, if thats the case http_vars_get will get the data wanted. And if its not, will work on modern installations (dispite being deprecated anyway)
Heinous
06-05-2007, 06:47 AM
dont work this is what im trying to do
$query = mysql_query("INSERT INTO entrys (pin) VALUES('$_GET['first'] . $_GET['second'] . $_GET['third'] . $_GET['final'];')");
It should be..
$query = mysql_query("INSERT INTO entrys (pin) VALUES('" . $_GET['first'] . $_GET['second'] . $_GET['third'] . $_GET['final'] . "')");
You had it wronggg.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.