gpt4 book ai didi

php - mysql_pconnect 不工作

转载 作者:行者123 更新时间:2023-11-29 12:43:55 24 4
gpt4 key购买 nike

我创建了一个 php 连接文件作为 explorecalirfornia.php 内容,如下所示。

#FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_explorecalirfornia = "localhost";
$database_explorecalirfornia = "explorecalirfornia";
$username_explorecalirfornia = "root";
$password_explorecalirfornia = "";
$explorecalirfornia = mysql_pconnect($hostname_explorecalirfornia, $username_explorecalirfornia, $password_explorecalirfornia) or trigger_error(mysql_error(),E_USER_ERROR);

我已使用命令将此 php 文件包含在我的页面中

<?php require_once('Connections/explorecalifornia.php'); ?> 

当我使用本地主机测试 php 代码时,抛出以下错误。

img

请帮助我完成我的教程。

最佳答案

  Either @mysql_pconnect($hostname_explorecalirfornia, $username_explorecalirfornia, $password_explorecalirfornia) or trigger_error(mysql_error(),E_USER_ERROR);  //@ infront of mysql_pconnect or use below written code

$mysqli = new mysqli(HOST, USERNAME, PASSWORD, DBNAME);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

关于php - mysql_pconnect 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25718399/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com