开发者

Why does mysql_connect break my .php?

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 "Connectin开发者_运维技巧g...", but nothing else. Doesn't even throw an error. I went through all the steps that were obvious. help?


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 :)


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?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜