Reputation: 4349
can someone help me with my query format. my output is:
UPDATE TABLE
SET Notes = 'testyyy',
0
WHERE Id = '1'
...when it should be:
UPDATE TABLE
SET Notes = 'testyyy ,
Notify = '0'
WHERE Id = '1'
PHP:
if(!isset($_POST['main'])) {
$up = "UPDATE TABLE SET Notes = '".$_POST["field"]."' ",";
$up .= " Notify = '".($data["Notes"] == '') ? '0' : '1'."'";
$up .= " WHERE Id = '".$_POST["id"]."'";
echo $up;
mysql_query ($up);
Upvotes: 0
Views: 274
Reputation: 212452
$up = "UPDATE TABLE SET Notes = '".$_POST["field"]."' ",";
doesn't look right
$up = "UPDATE TABLE SET Notes = '".$_POST["field"]."' ,";
and ensure that your $_POST values are escaped
Upvotes: 3
Reputation: 455302
Try using:
$up .= " Notify = '".($data["Notes"] == '' ? '0' : '1')."'";
or you can also split it into two as:
$up .= " Notify = '";
$up .= ($data["Notes"] == '') ? '0' : '1'."'";
Also TABLE
is a MySQL reserved word, you need to place it in back ticks.
Upvotes: 2
Reputation:
Move the ) to the other side of '1':
$up .= " Notify = '".($data["Notes"] == '' ? '0' : '1')."'";
Upvotes: 3