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

Posted by Rhys Drury on Stack Overflow See other posts from Stack Overflow or by Rhys Drury
Published on 2012-10-27T22:45:22Z Indexed on 2012/10/27 23:00 UTC
Read the original article Hit count: 141

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql