I tried this coding and it issues “MySQL server version for the right syntax to use near ‘’ at line 4” . I can not figure out the reason and once I comment the UPDATE statement the remaining code works fine. Please help me to solve this
[php]
<?php //error corde. error_reporting(E_ALL^E_NOTICE); $con=mysql_connect('localhost','root',''); mysql_select_db("ydms")or die(mysql_error()); // Search Button if (isset($_POST['search'])) { $cust_id=$_POST['cust_id']; $cust_name=$_POST['cust_name']; $cust_shop_name=$_POST['cust_shop_name']; //retriving data using customer number if($cust_id!='') { $query="SELECT * FROM customer WHERE cust_id='$cust_id'"or die(mysql_error()); $myquery=mysql_query($query); $sql=mysql_fetch_array($myquery)or die(mysql_error()); } //retriving data using customer name if($cust_name!='') { $query="SELECT * FROM customer WHERE cust_name='$cust_name'"or die(mysql_error()); $myquery=mysql_query($query); $sql=mysql_fetch_array($myquery)or die(mysql_error()); } //retriving data using shop name if($cust_shop_name!='') { $query="SELECT * FROM customer WHERE cust_shop_name='$cust_shop_name'"or die(mysql_error()); $myquery=mysql_query($query); $sql=mysql_fetch_array($myquery)or die(mysql_error()); } else { //echo "Please select one method to search"; } } //Update Button if(isset($_POST['Update'])){ $udtID=$sql['cust_id']; echo $udtID; $cust_contact_name=$_POST['cust_contact_name']; if (!preg_match('/^[a-zA-Z- ]+$/',$cust_contact_name)) { $valid = true; die( ' '); } $cust_contact1=$_POST['cust_contact1']; if (!preg_match('/^[0-9]{10}$/',$cust_contact1)) { $valid = true; die( ' '); } $cust_contact2=$_POST['cust_contact2']; if (!preg_match('/^[0-9]{10}$/',$cust_contact2)) { $valid = true; die( ' '); } $cust_remark=$_POST['cust_remark']; } $udtSql="UPDATE customer SET cust_contact_name='$cust_contact_name', cust_contact1='$cust_contact1', cust_contact2='cust_contact2', cust_remark='$cust_remark' WHERE cust_id=$cust_id "; $custUdt=mysql_query($udtSql) or die(mysql_error()); ?>[/php]
Exact Error :- You have an error in your SQL ; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 4