FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Connecting to DB





danway60
How do I connect to my Database using php?
I'm just trying stuff out atm.

I have
Code:
<?
/*--------- DATABASE CONNECTION INFO---------*/
$hostname="67.219.42.79";            (The IP address found using PHPinfo();   )
$mysql_login="danway60_Pages";   (Username)
$mysql_password="*********";
$database="danway60_Pages";       (The Database I want to connect to)

// connect to the database server
if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
  die("Can't connect to database server.");   
}else{
  // select a database
    if (!(mysql_select_db("$database",$db))){
      die("Can't connect to database.");
    }
}
?>





When using this code I get this:
Code:
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'danway60_Pages'@'host.frihost.net' (using password: YES) in /home/danway60/public_html/SQLDatabase/index.php on line 9
Can't connect to database server.


How do I fix this?
Thanks, Dan.
coreymanshack
hostname is localhost

Make sure you set up your database in cpanel or directadmin according to the information you have given.
danway60
Yeh I just found that out lol.

Thanks for the reply Very Happy
coreymanshack
No problem, glad you got it workin Razz
Related topics
script backup database
problem in sql and importing db.
Anyone?
Ftp Connecting Data Socket Problem....
Post- Nuke
Strange Mysql-database
Thumbs.db and _vti_cnf
PHP DB Error: syntax error
Advanced MySQL db merging Tutorials
Connecting to a mysql DB
Error connecting to mysql ; please help
Problem connecting to MySQL database with PHP [RESOLVED]
need help: cant call $db object from within my function
create swishmax Login with phpbb db
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.