richardstan Posted October 18, 2008 Share Posted October 18, 2008 Hi, I have the following function in a file called SQL.php: function connectDatabase($hostname, $user, $pass){ $link = @mysql_connect($hostname, $user, $pass); if(!$link){ print "<br>Failed to Connect to SQL Server"; } else{ print "<br>Connected to SQL Server"; } return $link; } Another file calls this function after using include("SQL.php"). However, there is no message saying whether the connection was successful or not. $hostname = "localhost"; $user = "****"; $pass = "****"; $link = connectDatabase($hostname, $user, $pass); I know that the SQL.php file is working fine because I have made it so a message comes up when there are no code errors. Can someone tell me why this might happen? Thanks Richard. Quote Link to comment https://forums.phpfreaks.com/topic/129008-no-error-thrown-after-fail-to-connect-to-mysql-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2008 Share Posted October 18, 2008 Add the following two lines immediately after your first opening <?php tag in your main file - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/129008-no-error-thrown-after-fail-to-connect-to-mysql-database/#findComment-668789 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.