Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php连接到mysql-php似乎永远在等待_Php_Mysql - Fatal编程技术网

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

使用php连接到mysql-php似乎永远在等待,php,mysql,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"; ?> 请帮忙 您是否尝试删

我刚刚开始学习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";
?>

请帮忙

您是否尝试删除@符号并检查日志以了解更多信息?另外,请尝试获取使用@来抑制警告的错误。。。删除它,它会在页面上显示错误。。。然后把上面两个人所说的错误贴在这里,对我造成的麻烦深表歉意。我不知道我应该用php下载mysql模块。安装了它,现在它工作正常。但您刚刚开始学习的几个技巧是:在开发时始终启用错误日志记录,除非您确切知道自己在做什么,否则永远不要使用
@
来抑制错误(无论您在使用它的interweb上发现了什么)
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