Marco M. Marco M. - 1 year ago 46
MySQL Question

Check the manual that corresponds to your MySQL server version for the right syntax: Update does not trasmit the data in the db because of this error

In the error it tells that the error is near

'UPDATE 'item' SET price='120' WHERE itemName ='Cebu - Manila Airpla' at line `2`

Here is my php code that adds the entry to the database

$updateEntry1 ="SET SQL_SAFE_UPDATES=0;
UPDATE 'item'
SET price='120'
WHERE itemName ='Cebu - Manila Airplane Ticket';";


Here is the retrieve table function which is a function that stores the info in the db

function retrieveTable($query){
$config = parse_ini_file('/config.ini');
$connect = mysqli_connect($config['servername'], $config['username'], $config['password'], $config['database']);
$filter_Result = mysqli_query($connect, $query)or die (mysqli_error($connect));
return $filter_Result;}

Answer Source

three aspect
firts be sure that you can use two sql statemnts in a single query with your sql driver

$updateEntry1 ="SET SQL_SAFE_UPDATES=0;

second... price should be a number and not a string

and third tablename without quote

                UPDATE  item
                SET price=120
                WHERE itemName ='Cebu - Manila Airplane Ticket';";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download