Dethman Posted June 6, 2008 Share Posted June 6, 2008 Heres the Code that I am using and the DB info is under it <?php session_start() or DIE("A session could not be created! Please Contact the administrator");; mysql_connect('localhost', '10352_reality', '123456') or DIE("UNABLE TO CONNECT TO DATABASE! Please Contact the administrator"); mysql_select_db('10352_reality') or DIE("UNABLE TO SELECT THE DATABASE! Please Contact the administrator"); ?> Now heres the DB info: Database Server Name: mysql Database: 10352_reality Username: 10352_reality Password: 123456 But I still get the "CANNOT CONNECT TO THE DATABASE" Error Cant Figure it out could it be the "Localhost" Thing Is there something else I can put there? Link to comment https://forums.phpfreaks.com/topic/108974-help-with-connecting-to-db/ Share on other sites More sharing options...
jesushax Posted June 6, 2008 Share Posted June 6, 2008 where the local host thing is is where you put the path or address/ip to the database Link to comment https://forums.phpfreaks.com/topic/108974-help-with-connecting-to-db/#findComment-559057 Share on other sites More sharing options...
Wolphie Posted June 6, 2008 Share Posted June 6, 2008 You shouldn't die a custom error, but you should die a mysql error. This is how a connection should be made <?php error_reporting(E_ALL); $con = mysql_connect('server_name', 'db_username', 'db_password') or die('MySQL Error: ' . mysql_error()); if($con) mysql_select_db('db_name') or die('MySQL Error: ' . mysql_error()); ?> Using mysql_error() will explicity give you the specific error as to why PHP can't make a connection to the database. Link to comment https://forums.phpfreaks.com/topic/108974-help-with-connecting-to-db/#findComment-559059 Share on other sites More sharing options...
Dethman Posted June 6, 2008 Author Share Posted June 6, 2008 THANK YOU YOU MOTHER SUCKER Link to comment https://forums.phpfreaks.com/topic/108974-help-with-connecting-to-db/#findComment-559080 Share on other sites More sharing options...
Wolphie Posted June 6, 2008 Share Posted June 6, 2008 Please mark the topic solved. Link to comment https://forums.phpfreaks.com/topic/108974-help-with-connecting-to-db/#findComment-559106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.