当前位置: 代码迷 >> PHP >> Use of undefined constant name - assumed 'name' in …的异常,代码如下
  详细解决方案

Use of undefined constant name - assumed 'name' in …的异常,代码如下

热度:431   发布时间:2012-05-28 17:59:54.0
Use of undefined constant name - assumed 'name' in ……的错误,代码如下:
function add_books(){
include_once("class_books.php"); //包含图书类
if($_POST["submit"]=="添加"){
if($_POST["add_book_name"]=="" || $_POST["add_book_price"]=="" || $_POST["add_book_author"]==""){
echo "<font color=red>添加失败,请把信息填写完整</font><br>";
echo "<a href=\"javascript:history.go(-1)\">重试</a>";
}
else{
$b=new books;
$b->__set(name,$_POST["add_book_name"]);
$b->__set(price,$_POST["add_book_price"]);
$b->__set(author,$_POST["add_book_author"]);
$b->add();
echo "图书$_POST[book_name]添加成功!<br>";
}
}
}
红字表示的是数据库中表的字段名

------解决方案--------------------
PHP code

$b->__set(name,$_POST["add_book_name"]); 
$b->__set(price,$_POST["add_book_price"]); 
$b->__set(author,$_POST["add_book_author"]); 
  相关解决方案