简体   繁体   English

使用NetBeans项目无法从php连接到mysql

[英]Not able to connect to mysql from php using netbeans project

I am trying to learn php on my own. 我正在尝试自己学习php。 Things were OK till i reach DB connection. 一切正常,直到我到达数据库连接为止。

I am using NetBeans 8.1 and had installed xampp to set up mysql and apache server. 我正在使用NetBeans 8.1,并安装了xampp来设置mysql和apache服务器。 But when i try to connect to DB using 但是当我尝试使用连接到数据库时

$dbPassword = "PHPpassword";
$dbUserName = "PHPuser";
$dbServer = "localhost";
$dbName = "PHPFirstDB";

$connection = new mysqli($dbServer, $dbUserName, $dbPassword, $dbName); 
print_r($connection);

Ideally i should be seeing $connection details but I am not able to see anything in the script output window. 理想情况下,我应该看到$ connection的详细信息,但是我无法在脚本输出窗口中看到任何内容。 I have set runas : script(run in command line) 我已经设置了runas:script(在命令行中运行)

Can anyone help me here... 有人能帮我一下吗...

Try this code, it could be possible that the error is occurring but not being displayed. 尝试使用此代码,可能会发生错误但未显示。

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

$connection = new mysqli($dbServer,$dbUserName,$dbPassword,$dbName);
if (mysqli_connect_error()) {
  die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}

print_r($connection);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM