This php file where abnormal, incredibly unable to run, this is the book Matching code AH Crazy

Source: Internet
Author: User
This PHP file where error, incredibly unable to run, this is the book Matching code AH. Crazy
The config.php file database user name and password are correct.

Error_reporting (E_all & ~e_notice);
$dbhost = ' localhost ';
$dbuser = ' root ';
$dbpass = ' password123 ';
$dbname = ' chap2 ';

Header (' content-type:text/html; CHARSET=GBK ');
Mysql_connect ($dbhost, $dbuser, $dbpass);
mysql_select_db ($dbname);
mysql_query (' SET NAMES gbk ');
?>


chap2.php code is as follows: Run display blank, exactly where is wrong???




<title>My bookshelf.</title>




My bookshelf.


Require_once ' config.php ';

$bookid = $_get[' edit '];

if ($_post[' submit ']) {
$title = $_post[' title '];
$author = $_post[' author ');
$dateline = $_post[' dateline ');
$price = $_post[' price '];

$setSQL = "bookid= ' $bookid ', title= ' $title ', author= ' $author ', dateline= ' $dateline ', price= ' $price '";
$sql = $bookid? "UPDATE Books set $setSQL WHERE bookid= ' $bookid '": "INSERT into books set $setSQL";
mysql_query ($sql);
Header (' Location:? ');
Exit
}

if ($bookid) {
$rs = mysql_query ("SELECT * from books WHERE bookid= ' $bookid '");
$book = Mysql_fetch_assoc ($RS);
}

if ($delid = $_get[' del ') {
mysql_query ("DELETE from books WHERE bookid= ' $delid '");
}

$rs = mysql_query ("SELECT * from books");

Echo '

List of books







'; while ($item = Mysql_fetch_assoc ($rs)) {echo " ";} Echo '
ID title author Publication Time Pricing Operation
$item [BookID] $item [title] $item [author] $item [Dateline] $item [Price] Modify Delete
';
Echo '

' . ($bookid? ' Modify the book ': ' New book '). '

';
?>




------Solution--------------------
Add an @ Mask error before the function that connects the database. Because the first time in PHP to connect to the database is an error, the program from the top down, will initialize the database. Causes a link problem.
------Solution--------------------
You open the error display function of PHP
PHP.ini in display_errors = On

So as long as the program is wrong, it will be displayed in the page
Don't make yourself yourself
  • Related Article

    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.