如何将信息添加到数据库中?

时间:2016-08-15 02:04:38

标签: javascript php html mysql mysqli

这似乎是一种正确的方法。它显示所有消息和显示。但它没有显示我真正的mysqli数据库。有人可以帮我找出它出错的地方吗? HTML输入正在读入PHP部分,除了数据库中没有显示的部分外,一切进展顺利。

提前致谢!

syntax error, unexpected '.', expecting ')'
...ty_comments, ->(potential_uses.project.profile.user_id) { wh...

<!DOCTYPE html>
<html>
<?php
    $con = mysqli_connect("localhost","root","","bookstore"); // Establishing Connection with Server
    echo 'Connected to database...';


    $Title = $_POST['Title'];
    $Author = $_POST['Author'];
    $Price = $_POST['Price'];
    $StateOfCopy = $_POST['StateOfCopy'];
    echo 'Data posted...';

    //Insert Query of SQL
    $sql = "INSERT INTO bookstore.booklist (`Title`, `Author`, `Price`, `StateOfCopy`)
             VALUES ('B10037', 'Children', $Title, $Author, $Price, 'Faerie Publishers','P10012', $StateOfCopy)";
    echo $Title;
    echo $Author;
    echo $Price;
    echo $StateOfCopy;

    // mysql_close($connection); // Closing Connection with Server
    /*
    INSERT INTO bookstore.booklist (`BookID`, `Category`, `Title`, `Author`, `Price`, `Publisher`, `PublisherID`, `StateOfCopy`) 
	VALUES ('B10036', 'Children', 'The Snow Queen', 'Hans Christian Anderson', 23.84, 'Faerie Publishers', 'P10012', '1st edition, Binded')
    */
    if($con->query($sql) === TRUE)
    {
        echo "<br/><br/><span>Data Inserted successfully...!!</span>";
    }
    else
    {
        echo "Error: ".$sql."<br>".$con->error;
    }
    $query = "SELECT * FROM bookstore.booklist";
    $result = mysqli_query($con,$query);

    $num = mysqli_num_rows($result);
    echo $num;
?>

0 个答案:

没有答案