wamp / php error致命错误:第9行的C:\ wamp \ www \ finalproject \ Connections \ Main_DB.php中找不到类'mysqli_connect'

时间:2015-01-05 09:50:47

标签: php mysql mysqli wamp

嗨,有人可以在这个问题上帮助我。

这是我的连接字符串:

<?php

    #FileName = "Connection_php_mysql.htm"
    #Type = "MYSQL"
    #HTTP = "true"

    $hostname_Main_DB = "localhost";
    $database_Main_DB = "mydb";
    $username_Main_DB = "root";
    $password_Main_DB = "";

    $con = new mysqli_connect($hostname_Main_DB,$username_Main_DB. $password_Main_DB, $database_Main_DB) or die ( "Failed to connect to MySQL: " . mysqli_connect_errno());     $db=mysqli_select_db($database_Main_DB,$con) or die( "Failed to connect to MySQL: " .     mysqli_connect_errno());
?>

我已安装wamp服务器且已启用mysqli扩展程序。

希望你能帮我解决这个问题,

Tnx,Yotam

2 个答案:

答案 0 :(得分:1)

$con = mysqli_connect(..);

删除新关键字。

答案 1 :(得分:0)

代码应

<?php

    #FileName = "Connection_php_mysql.htm"
    #Type = "MYSQL"
    #HTTP = "true"

    $hostname_Main_DB = "localhost";
    $database_Main_DB = "mydb";
    $username_Main_DB = "root";
    $password_Main_DB = "";

    $con = mysqli_connect($hostname_Main_DB,$username_Main_DB,$password_Main_DB, $database_Main_DB) or die ( "Failed to connect to MySQL: " . mysqli_connect_errno());

    $db=mysqli_select_db($database_Main_DB,$con) or die( "Failed to connect to MySQL: ".mysqli_connect_errno());
?>

你应该删除&#34; new&#34;。有关详细信息,请参阅 this

修改: -

此外,您已在两个应为.

的变量之间添加了,

$username_Main_DB. $password_Main_DB将其替换为$username_Main_DB,$password_Main_DB