Useofundefinedconstantname-assumed 'name' in... The code is as follows:

Source: Internet
Author: User
Useofundefinedconstantname-assumednamein ...... Code: functionadd_books () {include_once (& quot; class_books.php & quot;); contains the library class if ($ _ POST [& quot; submit & quot;] & quot; add & quo Use of undefined constant name-assumed 'name' in ...... The code is as follows:
Function add_books (){
Include_once ("class_books.php"); // contains the library class
If ($ _ POST ["submit"] = "Add "){
If ($ _ POST ["add_book_name"] = "" | $ _ POST ["add_book_price"] = "" | $ _ POST ["add_book_author"] = "") {
Echo "failed to add. please complete the Information
";
Echo "retry ";
}
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 "book $ _ POST [book_name] added successfully!
";
}
}
}
The red letter indicates the field name of the table in the database.

------ Solution --------------------
PHP code
$b->__set(name,$_POST["add_book_name"]); $b->__set(price,$_POST["add_book_price"]); $b->__set(author,$_POST["add_book_author"]);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.