0

I tried to install last version of MySQL in Centos 6.4 and execute the following command:

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

I ended up with a blank page result. Any advise?

Aan
  • 12,247
  • 36
  • 89
  • 150
  • you probably have your display_errors in your php.ini file set to false... set it to true will maybe permit you to get an error... otherwise check your error.log file (assuming you're on apache) to look for errors. – pataluc Jun 19 '13 at 12:03
  • [Reference - What does this error mean in PHP?](http://stackoverflow.com/q/12769982) – mario Jun 19 '13 at 12:05
  • I see this type of question all the time, you should read [common database debugging for PHP and MySQL](http://jason.pureconcepts.net/2013/04/common-debugging-php-mysql/). – Jason McCreary Jun 19 '13 at 12:09
  • *Obligatory:* The `mysql_*` functions will be [deprecated in PHP 5.5](http://php.net/manual/en/faq.databases.php#faq.databases.mysql.deprecated). It is not recommended for writing new code as it will be removed in the future. Instead, either the [MySQLi](http://php.net/manual/en/book.mysqli.php) or [PDO](http://php.net/manual/en/book.pdo.php) and [be a better PHP Developer](http://jason.pureconcepts.net/2012/08/better-php-developer/). – Jason McCreary Jun 19 '13 at 12:09

2 Answers2

2

add below 2 line on top of your code, you will see error.

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '1');
VibhaJ
  • 2,256
  • 19
  • 31
  • If there's a syntax error below that, no part of the script will be parsed or run. Hence error_reporting not be enabled still. – mario Jun 19 '13 at 12:06
0

Make sure php_mysql extension is installed and available.

Azfar Niaz
  • 1,516
  • 4
  • 13
  • 21