我有 2 个数组,$arr
用于旧菜单名称和$arr1
新菜单名称。我想用数据库中的新菜单名称替换旧菜单名称。我有以下代码,但它抛出了一个错误。
<?php
$arr = explode(',', preg_replace('/^.*\[(.*)\].*$/', '$1', trim($_POST['menuname'],
'[]')));
$arr1 = explode(',', preg_replace('/^.*\
[(.*)\].*$/', '$1', trim($_POST['editmainmenu'], '[]')));
mysql_connect("localhost", "root", "root");
mysql_select_db("test");
foreach ($arr as $key => $value)
{
$value1 = $arr1[$key];
mysql_query("update test set (menuname) =('" .
mysql_real_escape_string($value1) . "') where menuname=('" .
mysql_real_escape_string($value) . "')")or
die('unable' . mysql_error());
echo "updated";
}
?>
我收到以下错误:
04-09 19:06:27.201: I/System.out(1291): unableYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(menuname) =('') where menuname=('Food Menu')' at line 1
请告诉我如何解决这个问题。谢谢!