I wrote a php code to replace SQL row values. But it is not working as expected
ERROR : Parse error: syntax error, unexpected T_STRING in ...... on line 3
I think i should not use these quotes " "
right ? But, when i ran this without " "
got this error
Error updating comment table: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
Here is my Code
<?php
include_once("db.php");
$sql1 = "update table1 set marks = replace(c2,"NK",'NOKIA')";
$sql2 = "update table1 set marks = replace(c2,"SM",'SAMSUNG')";
$sql3 = "update table1 set marks = replace(c2,"A",'APPLE')";
$sql4 = "update table1 set marks = replace(c2,"CH",'CHINAPECE')";
$sql5 = "update table1 set marks = replace(c2,"WO",'WORLDCLASS')";
if (mysql_query($sql1 && $sql2 && $sql3 && $sql4 && $sql5))
{
echo "Replaced.";
}
else
{
echo "Error in replacing: " . mysql_error();
}
?>
Thank you!
UPDATE (updated php code with sujjestions sugested by Trinimon and beiller)
ERROR : Parse error: syntax error, unexpected ';' in .... on line 8
<?php
include_once("db.php");
$sql1 = "update table1 set marks = replace(c2,"NK",'NOKIA')";
$sql2 = "update table1 set marks = replace(c2,"SM",'SAMSUNG')";
$sql3 = "update table1 set marks = replace(c2,"A",'APPLE')";
$sql4 = "update table1 set marks = replace(c2,"CH",'CHINAPECE')";
$sql5 = "update table1 set marks = replace(c2,"WO",'WORLDCLASS')";
if (mysql_query($sql1);
mysql_query($sql2);
mysql_query($sql3);
mysql_query($sql4);
mysql_query($sql5);)
{
echo "Replaced.";
}
else
{
echo "Error in replacing: " . mysql_error();
}
?>
ERROR : Parse error: syntax error, unexpected ';' in .... on line 8