Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/293742-posting-to-mssql-based-on-two-criteria/
Share on other sites

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 by Butterbean

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.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.