mangtas_ka Posted September 19, 2014 Share Posted September 19, 2014 Hello everybody, I am new to php, I have a question for you guys. why I've got an empty page. <?php //MySQL database connection //connect_db.php $host="localhost"; // Host name $username="root"; // Mysql username $password="logans1966"; // Mysql password $db_name="Inventory"; // Database name $conn = mysql_connect("$host","$username","$password") or die(mysql_error()); mysql_select_db("$db_name")or die("cannot select DB"); if ($conn) { echo ("Connection is succeed"); } else { echo ("Connection is fail"); } ?> thanks in advance cris Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/ Share on other sites More sharing options...
mangtas_ka Posted September 19, 2014 Author Share Posted September 19, 2014 I've also try $conn = mysql_connect($host,$username,$password) or die(mysql_error("Unable to Connect")); same result Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/#findComment-1491573 Share on other sites More sharing options...
mac_gyver Posted September 19, 2014 Share Posted September 19, 2014 what do you get when you do a 'view source' of the empty page in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/#findComment-1491576 Share on other sites More sharing options...
cyberRobot Posted September 19, 2014 Share Posted September 19, 2014 Do you know if PHP is set to display all errors and warnings? Note that you can add the following to the top of your script to show them: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?> Side note: Perhaps you are already aware of this, but the mysql_* functions have been deprecated. At some point in the near future, you'll need to switch to PDO or MySQLi. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/#findComment-1491590 Share on other sites More sharing options...
mogosselin Posted September 19, 2014 Share Posted September 19, 2014 What you want to do when you develop (meaning on your computer or a test server or whatever) is to display ALL of the messages PHP can send to you so that you can fix them as soon as possible. When your code is 'live' (accessible from the Internet), you want to display a nice custom error page. You certainly don't want to show to your users error messages coming from PHP. It's not secure, it's ugly and it won't help your users anyway. But, you want to be able to see the errors, that's why you should at least log them. To try what's happening on your server (either it's on your production or development server), you can create a single PHP file with only this content: <?php foo(); The function 'foo()' shouldn't exist, so when you call that page, you should see an error message. If you see a white page, it's because your PHP error settings tells PHP not to output any error. If you actually want to see the errors, you could change your settings in php.ini to: display_errors=On error_reporting=E_ALL log_errors=1 Or, if you want to (but it's not the cleanest way), you can add this to your code: ini_set('display_errors','On');ini_set('log_errors',1);ini_set('error_reporting',E_ALL); If you want to know more, I wrote an article about Error settings with PHP. If you read it, I'd love to have your comments! Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/#findComment-1491591 Share on other sites More sharing options...
gristoi Posted September 19, 2014 Share Posted September 19, 2014 ALSO MYSQL_* IS DEPRECATED, USE PDO Quote Link to comment https://forums.phpfreaks.com/topic/291159-empty-page/#findComment-1491596 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.