需要一些帮助。我的网站没有与数据库连接。
这是我的代码:
<?php
$serverName="localhost";
$dbusername="root";
$dbpassword="";
$dbname="bank_db";
mysql_connect($serverName,$dbusername,$dbpassword)/* or die('the website
is down for maintainance')*/;
mysql_select_db($dbname) or die(mysql_error());
?>
非常感谢您的帮助。
谢谢!
最佳答案
我也遇到过同样的情况,下面的代码块对我来说很好:
<?php
// URL Connection
$host='localhost';
$uname='root';
$pwd='';
$db='databasename';
//I created a connection object here to establish the connection with my database
$con = mysql_connect($host,$uname,$pwd) or die("connection failed/");
mysql_select_db($db,$con) or die("db selection failed");
?>
希望有效,
谢谢。
关于php - 需要使用 wamp 连接我的 mysql 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47586530/