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
ID |
title |
author |
Publication Time |
Pricing |
Operation |
'; while ($item = Mysql_fetch_assoc ($rs)) {echo "
$item [BookID] |
$item [title] |
$item [author] |
$item [Dateline] |
$item [Price] |
Modify Delete |
";} Echo '
';
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