bruckerrlb Posted August 4, 2007 Share Posted August 4, 2007 Hello, I am not exactly sure what i'm doing wrong here, but I am trying to make mysql find the specific user with a select statement, and then insert data about this user into his record. This is my code //this top connection part is not the problem, it's after the brown $qry = "INSERT INTO products (productid, productname, telefone, fetchaalta, fetchabaja, clientid) VALUES ('$_POST[productnumber]', '$_POST[productname]', '$_POST[telefone]', '$_POST[desde]', '$_POST[hasta]', '$_POST[clientid]')"; if (!@mysql_query ($qry)) { die(mysql_error()); } else { $client = $_POST[cliente]; $getuser = 'SELECT id FROM login WHERE id = '$client''; if ($r = mysql_query ($getuser)) { while ($row = mysql_fetch_array ($r)) { //Create INSERT query $query = "INSERT INTO login (fetchaalta, fetchabaja) VALUES ('$_POST[altacliente]', '$_POST[bajacliente]')"; if (!@mysql_query ($query)) { die("possible problem here".mysql_error()."problem in loginquery"); } } } else { header("location: admin_menu.php"); exit; } } I am getting the dreded parse error, unexpected T_Variable, but the main problem is i'm pretty sure my logic is not right, and I am wondering how to go about setting this up iif anyone is good with mysql logic it would be a great help to me, thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/63325-using-select-statement-as-a-loop-to-insert-data/ Share on other sites More sharing options...
Illusion Posted August 6, 2007 Share Posted August 6, 2007 First of all make sure that ur php variable are interpreted and if not , try this VALUES ('{$_POST['productnumber']}',..............) is this what u r looking for ur second insert query INSERT INTO login (fetchaalta, fetchabaja) VALUES ('$_POST[altacliente]', '$_POST[bajacliente]') where id=ANY (SELECT id FROM login WHERE id = '$client') Quote Link to comment https://forums.phpfreaks.com/topic/63325-using-select-statement-as-a-loop-to-insert-data/#findComment-316587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.