简体   繁体   中英

MySQL Access in Php to a database created in C-Panel

Basically, i'm having trouble connecting to a mysql database using a php web page. I created the database in C-panel using the wizard i'm connecting like this

$db_host = "localhost"; //your host Database address

$db_username = "xxxx"; //your account username

$db_pass = "xxxxx"; //your account password

$db_name = "xxxxx"; //your database name

@mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to     mysql");

@mysql_select_db("$db_name") or die ("no database");

But all my page seems to do is trigger the " could not connect to mysql" my page does have wordpress installed at the minute but I'm planning to get rid of it as I'm creating my site myself. I'm just baffled why it can't connect, because in Phpmyadmin ( a feature on C-panel) it says the database is in localhost.

在C-panel中,您需要添加数据库用户并为其分配某些角色,然后才能连接到数据库。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM