的config.php
$host = 'REMOVED';
$dbname = 'REMOVED';
$username = 'REMOVED';
$password = 'REMOVED';
try {
$db = new PDO("mysql:host=".$host.";dbname=".$dbname, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
} catch(PDOException $e) {
exit($e->getMessage());
}
配置连接到服务器就好了,然后我尝试在index.php中向表中插入一行,然后......
的index.php
require 'config.php';
$text1 = 'teeext';
$text2 = 'teeeext';
$text3 = 'teeeeext';
$db->exec('INSERT INTO users (`row1`, `row3`, `row2`) VALUES ('.$text1.', '.$text2.', '.$text3);
当我运行此页面时,我只是空白,数据库不显示插入的任何行,即使我运行页面100次。
答案 0 :(得分:-1)
在您未关闭'.$text3.'
$db->exec('INSERT INTO users (`row1`, `row3`, `row2`) VALUES ('.$text1.', '.$text2.', '.$text3.')');