petroz Posted October 1, 2009 Share Posted October 1, 2009 Hi Guys, I am having some troubles with this script. The goal is to get a unique ID from one table, store it as a array, then with another query update a second table using information from the first table all related to that first array created on the first query. I am getting "Parse error: syntax error, unexpected T_STRING" on the first line of the second query. I am pretty knew at this.... so please forgive any stupid mistakes or complete misunderstandings. Thanks, P <? include "db.php"; $uid = $_GET['uid']; $request = $_GET['req']; $requid = $_GET['requid']; $getresp = "SELECT resp_uid FROM requests WHERE request = '$req'"; $result = mysql_query($getresp) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); $accept = "UPDATE requests2 SET `status` = '$status', `resp_name` = (SELECT `name` FROM `users` WHERE `uid` = '.$row'), `resp_organization` = (SELECT `organization` FROM `users` WHERE `uid` = '.$row'), `resp_email` = (SELECT `email` FROM `users` WHERE `uid` = '.$row'), `resp_phone` = (SELECT `phone` FROM `users` WHERE `uid` = '.$row'), `resp_url` (SELECT `email` FROM `users` WHERE `uid` = '.$row'), `resp_im` = (SELECT `im` FROM users WHERE `uid` = '.$row'), `resp_address` = (SELECT `address` FROM `users` WHERE `uid` = '.$row')"; $acceptresult = mysql_query($accept) or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted October 1, 2009 Share Posted October 1, 2009 with the way you've got it you're missing some quotes and some concatenation and the keys for $row, and a couple of equals $accept = "UPDATE requests2 SET `status` = '".$status."', `resp_name` = (SELECT `name` FROM `users` WHERE `uid` = '".$row['resp_uid']."'), `resp_organization` = (SELECT `organization` FROM `users` WHERE `uid` = '".$row['resp_uid']."'), `resp_email` = (SELECT `email` FROM `users` WHERE `uid` = '".$row['resp_uid']."'), `resp_phone` = (SELECT `phone` FROM `users` WHERE `uid` = '".$row['resp_uid']."'), `resp_url`= (SELECT `email` FROM `users` WHERE `uid` = '".$row['resp_uid']."'), `resp_im` = (SELECT `im` FROM users WHERE `uid` = '".$row['resp_uid']."'), `resp_address` = (SELECT `address` FROM `users` WHERE `uid` = '".$row['resp_uid']."')"; But...I would use a join for the first query $getresp = " SELECT users.name, users.organization, users.email, users.phone, users.email as url, users.im, users.address FROM requests JOIN users on requests.resp_uid=users.uid WHERE resp_uid.request = '$req' "; then $result = mysql_query($getresp) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $accept="UPDATE requests2 SET `status` = '".$status."', `resp_name` = '".$row['name']."'), `resp_organization` = '".$row['organization']."', `resp_email` = '".$row['email']."', `resp_phone` = '".$row['phone']."', `resp_url`='".$row['url']."', `resp_im` = '".$row['im']."', `resp_address` = '".$row."' where uid='".$row['uid']; } you'll need to double check me, some of the column names and keys might be wrong. Quote Link to comment 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.