0

有些东西我无法用 PHP 中的 PDO 解释。我想使用 php 脚本在名为“base.sql”的数据库(sqlite)上插入数据:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <html>
<head>
<title> liste </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1> Liste </h1>
<?php

$dsn = 'sqlite:base.sql';
$conn = new PDO($dsn);    

$sql_mins ="INSERT INTO voiture(nom,description,prix) VALUES ( 'Peugeost208','Grise, 90 cheveaux',8500 )";
$conn->query($sql_mins);

$sql = "SELECT * FROM voiture";
$result =$conn->query($sql);
foreach ($result as $row)
{
echo $row['pk'] ." :". $row['nom']." ".
$row['description']." ".$row['prix']." € <br />";
}
?>
</body>
</html> 

根据需要显示我使用 linux 终端放在我的基础上的数据。但是,我使用“$sql_mins”和“$conn->query($sql_mins);”插入的数据 不显示。有人知道我脚本上的错误在哪里吗?

4

1 回答 1

0

您的描述栏中有一个逗号,您必须使用 addlashes 对其进行转义

于 2013-05-11T11:45:19.807 回答