无法使用NetBeans项目从php连接到mysql [英] Not able to connect to mysql from php using netbeans project

查看:109
本文介绍了无法使用NetBeans项目从php连接到mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自己学习php.一切正常,直到我到达数据库连接为止.

I am trying to learn php on my own. Things were OK till i reach DB connection.

我正在使用NetBeans 8.1,并安装了xampp来设置mysql和apache服务器.但是当我尝试使用

I am using NetBeans 8.1 and had installed xampp to set up mysql and apache server. 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);

理想情况下,我应该看到$ connection的详细信息,但是我无法在脚本输出窗口中看到任何内容.我已经设置了runas:script(在命令行中运行)

Ideally i should be seeing $connection details but I am not able to see anything in the script output window. I have set runas : script(run in command line)

有人可以在这里帮助我吗...

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

这篇关于无法使用NetBeans项目从php连接到mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆