echosara Posted August 3, 2014 Share Posted August 3, 2014 Hi I am trying to connect to my database but i am having some problems where the server( WAMP) crashes and does not load this page. here is the php coding <?php $db = new PDO("mysql:host=localhost;dbname=test;port=80", "root", ""); var_dump($db); when i run this no error comes the page doesnt load. anyone know why? when using PDO do i have to do some sort of configuration changes to wamp? i have even changed the directory of the file and still same issue. any suggestions would be wonderful. Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/ Share on other sites More sharing options...
Solution mac_gyver Posted August 3, 2014 Solution Share Posted August 3, 2014 you are likely getting a fatal runtime error. do you have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system so that php would report and display all the errors it detects? Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486768 Share on other sites More sharing options...
Jacques1 Posted August 4, 2014 Share Posted August 4, 2014 (edited) Why do you tell PDO that the database system is running on port 80? That's the port for HTTP, i. e. your webserver. The default port for MySQL is 3306. Unless you've changed this setting, just leave out the port parameter. // Actually, this makes no sense at all. “localhost” means that you're connecting via a Unix domain socket. On the other hand, the port indicates that you're trying to connect via a network socket (IP + port). So which one is it? Edited August 4, 2014 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486772 Share on other sites More sharing options...
echosara Posted August 4, 2014 Author Share Posted August 4, 2014 i added error reporting to the script to make it like this <?php $db = new PDO("mysql:host=localhost;dbname=test", "root", ""); var_dump($db); error_reporting(E_ALL); i would like to turn on display_errors on in php.ini; however i am having a hard time locating that in my wamp server. can you provide any directory to guide me. Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486777 Share on other sites More sharing options...
Jacques1 Posted August 4, 2014 Share Posted August 4, 2014 It doesn't help to turn on error reporting after the error has happened. You obviously need to do that before the error, either in the php.ini file or on top of the script. The phpinfo() function tells you where your php.ini file is located. Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486778 Share on other sites More sharing options...
boompa Posted August 4, 2014 Share Posted August 4, 2014 http://forum.wampserver.com/read.php?2,45057,45079 Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486783 Share on other sites More sharing options...
echosara Posted August 5, 2014 Author Share Posted August 5, 2014 i got it working ....Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486828 Share on other sites More sharing options...
Jacques1 Posted August 5, 2014 Share Posted August 5, 2014 And the problem was what? Quote Link to comment https://forums.phpfreaks.com/topic/290257-connecting-to-database-using-php-objects/#findComment-1486829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.