Ask the Saints to check where the following code is wrong

Source: Internet
Author: User
Ask the expert to check where the code below is wrong.
The code follows, adding a prompt to add a failure.


Phpinfo ();
This is a message to increase, delete, change the operation of the processing page

First, import the configuration file.
Require ("dbconfig.php");
Second, link MySQL, and select the database.
$link = @mysql_connect (Host,user,pass) or Die ("Database link Error! ");
mysql_select_db (DBNAME, $link);
Third, according to the value of action, to determine the operation, execute the corresponding code.
Switch ($_get["action"]) {
Case "Add"://Execute add
1. Get the information you want to add and supplement other information
$title = $_post["title"];
$keywords = $_post["keywords"];
$author = $_post["Author"];
$content = $_post["Content"];
$addtime = time ();
2, add information over filter (omitted)
3. Assemble and add SQL statements and perform add operations
$sql = "INSERT INTO news Valuse (null, ' {$title} ', ' {$keywords} ', ' {$author} ', ' {$addtime} ', ' {$content} ')";
Echo $sql; This step prints normally.
mysql_query ($sql, $link);
4, to determine whether to add success,
$id = mysql_insert_id ($link);//Determine the information ID value you just added
echo $id;
Break
if ($id >0) {
Echo

Add success

";
}else{
Echo

Add failed

";
}
Break

Case "Del"://Execute Delete

Break

Case "Update"://Perform modification

Break

}
Iv. Closing the database
Mysql_close ($link);
?>



------Solution--------------------
First paragraph: insert?into?news? Valuse
Second paragraph: INSERT INTO news Values
One is valuse and the other is valuse.
  • 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.