亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

This code neither prompts an error nor can I see the result. Please tell me where the error is. Thank you!
邯鄲易住宋至剛
邯鄲易住宋至剛 2019-08-01 20:48:35
0
7
1828

<?php
/**
Use PDO to complete the database connection
*/
require 'pdo_conf.php';
try
{
$pdo = new PDO($dsn,$userName ,$password);
//echo '<h3>Connection successful</h3>';
$sql = "INSERT student (id,name,course,grade) VALUES ('11',Wu Song ','mysql','80')";
$num = $pdo->exec($sql);
$insertId = $pdo->lastInsertId();
if($ NUM & GT; 0) {
PRINT 'successfully added'. $ NUM. 'Receives, and the new primary key ID was'. $ insertid;
}
} cach (pdoexception $ e) {
die('Operation failed'.$e->getMessage());
}

邯鄲易住宋至剛
邯鄲易住宋至剛

http://ipnx.cn/course/1073.html

reply all(4)
王先生

ID is self-increasing and automatically generated. It can't be inserted.

V

Add echo 'Insertion successful!' directly below $num = $pdo->exec($sq);

Please let me know if it is incorrect! Thanks!

  • reply Hello, after inserting echo 'insert successfully', run, the page displays "insert successfully", but no data is inserted into the data table.
    邯鄲易住宋至剛 author 2019-08-21 10:20:27
邯鄲易住宋至剛

The database connection is successful, no problem

Peter-Zhu

I don’t see your connection code, not sure if your connection is successful? You can print out the SQL statement and see if it is correct? Or directly execute it in the SQL command line to locate the error?

  • reply Hello, the sql statement is placed in the data table and executed using SQL commands, and the data can be successfully inserted.
    邯鄲易住宋至剛 author 2019-08-21 10:23:34
  • reply Use mysqli_connect method to connect to the database. The parameters are the same. The connection can be normal and the data can be inserted normally.
    邯鄲易住宋至剛 author 2019-08-21 14:40:24
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template