Butterbean Posted January 8, 2015 Share Posted January 8, 2015 This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql. <?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql); Thank you for any help. Quote Link to comment https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/ Share on other sites More sharing options...
Butterbean Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) thought this would work but did not. $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'& meter_id = '$meter_id' "; Edited January 8, 2015 by Butterbean Quote Link to comment https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/#findComment-1502098 Share on other sites More sharing options...
CroNiX Posted January 8, 2015 Share Posted January 8, 2015 Are you using $_POST or $_GET? Because in your first lines of code you are using both, which is odd. Regarding your query, you should use double ampersands (&&) or better to just use "AND" for the logical operator. I don't believe a single & means anything. 1 Quote Link to comment https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/#findComment-1502101 Share on other sites More sharing options...
Butterbean Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) we are getting the start date and meter id from the db to authenticate the customer, then we are subsequently posting data back to the server. Edited January 8, 2015 by Butterbean Quote Link to comment https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/#findComment-1502103 Share on other sites More sharing options...
Butterbean Posted January 8, 2015 Author Share Posted January 8, 2015 Got it! Messed my AND up. That resolved the issue.. Thanks a million! Quote Link to comment https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/#findComment-1502104 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.