php An error occured_PHP教程
程序员文章站
2022-04-02 09:44:55
...
function install_postgresql($name, $mail, $title, $content){
$pgsql_conn = pg_connect("host=localhost port=5432 dbname=book user=vi");
if (!$pgsql_conn) {
echo "connect database error.\n";
exit;
}
$result = pg_query($pgsql_conn, "INSTER INTO topic (man, mail, title, content) VALUES ('$name', '$mail', '$title', '$content');");
if(!$result){
echo "An error occured.\n";
exit;
}
pg_close($pgsql_conn);
}
?>
$pgsql_conn = pg_connect("host=localhost port=5432 dbname=book user=vi");
if (!$pgsql_conn) {
echo "connect database error.\n";
exit;
}
$result = pg_query($pgsql_conn, "INSTER INTO topic (man, mail, title, content) VALUES ('$name', '$mail', '$title', '$content');");
if(!$result){
echo "An error occured.\n";
exit;
}
pg_close($pgsql_conn);
}
?>
注要是你在sql后面加了;号,去了就行了,
推荐阅读
-
php 不能连接数据库 php error Can't connect to local MySQL server
-
非集成环境的php运行环境(Apache配置、Mysql)搭建安装图文教程
-
PHP的Yii框架中Model模型的学习教程
-
php 不能连接数据库 php error Can't connect to local MySQL server
-
php识别微信客户端并且使用html静态页面引导用户使用浏览器打开这个页面(代码实现教程)
-
PHP的Yii框架中使用数据库的配置和SQL操作实例教程
-
PHP小教程之实现链表
-
PHP面向对象教程之自定义类
-
PHP小教程之实现双向链表
-
PHP中调用C/C++制作的动态链接库的教程