WAMFT1 Posted February 13, 2015 Share Posted February 13, 2015 I am trying to setup so that I select a name from the dropdown menu (already works) then taking the ID number and using it to update multiple tables. I cannot get it to update anything. I don't really know what I am doing here, I thought based on other coding I have used that this would be simple. Please Help?? <? require('../edb.php'); $aid =$_REQUEST['aid']; if (isset($_POST['Submit'])) { $mysql_query1("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query2("UPDATE `adocs_cpd` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query3("UPDATE `adocs_fds` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query4("UPDATE `adocs_fsg_profile` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query5("UPDATE `adocs_sapl` SET Current='N' WHERE AdviserCode='$aid'"); }?> Quote Link to comment Share on other sites More sharing options...
Solution cyberRobot Posted February 13, 2015 Solution Share Posted February 13, 2015 You'll want to review the documentation for the mysql_query() function: http://php.net/manual/en/function.mysql-query.php Basically, your queries should look more like the following: mysql_query("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); Note that I removed the dollar sign and number from the call to mysql_query(). Also note that your queries are vulnerable to SQL injection attacks. Since it looks like $aid is a string, you want to escape the value with the following function: http://php.net/manual/en/function.mysql-real-escape-string.php Quote Link to comment Share on other sites More sharing options...
WAMFT1 Posted February 15, 2015 Author Share Posted February 15, 2015 Thanks cyberRobot The update now works, I have also added in the real escape string. Thanks for the links. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted February 17, 2015 Share Posted February 17, 2015 No problem, glad to help! 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.