2

I have the following code running on Apache 2.2 with PHP 5.3.3:

<html>
<body>
<?php
error_reporting(E_ALL);

echo "Connecting...";

$conn = mysql_connect('127.0.0.1:3306','root','*******') or die('Error connecting to mysql');

echo 'Connected.';
?>
</body>
</html>

And it prints out "Connecting...", but nothing else. Doesn't even throw an error. I went through all the steps that were obvious. help?

Bloodyaugust
  • 2,463
  • 8
  • 30
  • 46

3 Answers3

3

error_reporting(E_ALL); might sometimes not do it. Use it in combination with:

ini_set('display_errors', 1);

and see if it returns an error then :)

ajreal
  • 46,720
  • 11
  • 89
  • 119
Tjirp
  • 2,435
  • 1
  • 25
  • 35
  • +1 If `display_errors` is set to *off* and the mysql extension is not loaded, you can get the symptoms described. – Álvaro González Dec 09 '10 at 16:44
  • That. Is so. Weird. I specifically set display_errors to on IN ALL CASES in my php.ini. Perhaps its using a different one... or not. I don't have another. Anyways, this worked. I get "Fatal error: Call to undefined function mysql_connect() in *****.php on line 15. Buh. Thanks! – Bloodyaugust Dec 09 '10 at 17:56
1

Test skipping the port notation since you are specifying the default port anyways.

What does your Apache error log say?

What does var_dump($conn) print out?

0
<?php
$conn = mysql_connect('127.0.0.1:3306','root','*******')
if (!$conn ) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($conn );
?>
Pradeep Singh
  • 3,582
  • 3
  • 29
  • 42