使用php连接到mysql - php似乎永远等待

时间:2014-02-02 12:39:50

标签: php mysql

我刚开始学习php,我写了以下代码:

<?php
echo "starting";
$link = @mysqli_connect('localhost', 'root', 'abc123', 'phptest');

if (!$link) {
    die('Connect Error: ' . mysqli_connect_errno());
}
else
{
    echo "it worked!";
}
echo "finished";
?>

我得到的只是

起始

作为我的输出。我安装了mysql,它运行在localhost上。我用它验证了它:

mod@mod-Inspiron-N5110:/var/www# mysql --host=localhost --user=root --password=abc123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.5.34-0ubuntu0.13.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use phptest
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

请帮忙!

0 个答案:

没有答案