我在xampp的phpmyadmin中创建了我的数据库“MUSIC”。我正在尝试使用我存储在OML文件夹中的php文件连接到此数据库,而该文件又存在于htdocs文件夹中,我的代码是:
$db_name="MUSIC";
$db_user="root";
$db_pwd="ash123";
$db_host="localhost";
$connect = mysql_connect("localhost","root","ash123");
mysql_select_db("MUSIC");
echo "connection successful";
但是当我转到localhost并输入localhost/connect.php
时,我收到此错误:
Object not found!
the requested URL was not found on this server.if u entered the URL manually please check your spelling and try again.If you think this is a server error,please contact webmaster.
Error 404
localhost
Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7
我已经搜索了但是我找到了解决这个问题的方法,请帮忙!
答案 0 :(得分:1)
我正在尝试使用我拥有的php文件连接到此数据库 将存储在OML文件夹中,而OML文件夹又存在于htdocs文件夹中
因此,URI将是/OML/connect.php
,而不仅仅是/connect.php
,对吧?
答案 1 :(得分:0)
尝试在地址栏中输入:“localhost / OML / connect.php”
答案 2 :(得分:0)
$connect = mysqli_connect("localhost","root","ash123","MUSIC");
在数据库连接文件中替换此代码。删除您显示的代码。
答案 3 :(得分:0)
mysql_connect()
为deprecated,您不正确地选择了数据库。
您的代码应为:
$db_name="MUSIC";
$db_user="root";
$db_pwd="ash123";
$db_host="localhost";
$link = mysqli_connect($db_host, $db_pwd, $db_name);
if (!$link->connect_error) {
echo "connection successful";
} else {
echo $link->connect_error
}
此时建立连接,并选择DB。
答案 4 :(得分:0)
请尝试将其连接到您的数据库
SELECT bundle_id,asset_id ,
(CASE
WHEN weekday_am IS NULL or weekday_am = 0.00 where customer_id = 5 and price_id = 3 THEN weekday_am
WHEN weekday_am IS NULL or weekday_am = 0.00 where price_id = 2 THEN weekday_am
ELSE weekday_am IS NULL or weekday_am = 0.00 where price_id = 1 THEN weekday_am
END as 'weekday_am'),(CASE
WHEN weekend_am IS NULL or weekend_am = 0.00 where customer_id = 5 and price_id = 3 THEN weekend_am
WHEN weekend_am IS NULL or weekend_am = 0.00 where price_id = 2 THEN weekend_am
ELSE weekend_am IS NULL or weekend_am = 0.00 where price_id = 1 THEN weekend_am
END as 'weekend_am')
FROM
bundle_prices where bundle_id = 1