Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql_connect error

Tags:

php

In the following code I see echo1 statement, after which I do not see anything printed on the UI.The username and password is correct. But PHP doesn't seem to connect to MySQL. Don't even see the die statement what am I doing wrong. After mysql_connect is encountered the rest of the code doesn't work:

<?php    
echo "echo1==========";
$con = mysql_connect("localhost","root", "xxxx123") or die("Error connecting to database");
echo "+++++++++ echo2";
echo $con;
mysql_close($con);
  ?>          
like image 953
Rajeev Avatar asked Oct 27 '12 13:10

Rajeev


2 Answers

You should be mising an error. Add :

ini_set('display_errors', 1);
error_reporting(E_ALL);

at the beggining of your script

like image 84
Jscti Avatar answered Sep 24 '22 00:09

Jscti


No output means a fatal error. The only possible fatal error is "undefined function mysql_connect (unless something's really messed up somewhere). This means the mysql library is not installed, or it might just not be enabled in the php.ini file.

Check said file, and while you're at it turn error_reporting on.

like image 24
Niet the Dark Absol Avatar answered Sep 26 '22 00:09

Niet the Dark Absol