[英]PHP POSTGRESQL database connection
if I use this code to connect database it is showing nothing, if I give wrong database name also it is not showing error I'm using this code in ubuntu 16.04.如果我使用此代码连接数据库,它什么也没有显示,如果我给出错误的数据库名称也没有显示错误我在 ubuntu 16.04 中使用此代码。 path var/www/html
路径 var/www/html
<?php
//dvdstoredbfunctions.php
// Global Variables
$host="localhost";
$port="";
$db_name="dvd_store";
$options="";
$tty="";
$db_user="dvd_user";
$db_password="";
$err_mesg;
$db_conn;
You have to use pg_connect
to connect to postgresql
.您必须使用
pg_connect
连接到postgresql
。 If you want to use PDO
see this article , or php documentation .如果你想使用
PDO
看这篇文章,或者php 文档。 For pg_connect
, I suggest you to do this:对于
pg_connect
,我建议你这样做:
$conn_string = "host=".$host." port=".$port." dbname=".$db_name." user=".$db_user." password=".$db_password;
$db_conn = pg_connect($conn_string);
If it's not connecting try to change $port
to 5432
.如果没有连接,请尝试将
$port
更改为5432
。 5432
is default port value of postgresql
. 5432
是postgresql
的默认端口值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.