wamp / php error Fatal error: Class 'mysqli_connect' not found in C:\wamp\www\finalproject\Connections\Main_DB.php on line 9 [duplicate]

情到浓时终转凉″ 提交于 2019-12-25 19:04:08

问题


hi could someone assist me in this issue.

this is my connection string:

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

I have installed wamp server and mysqli extension is enabled.

hope you will be able to help me with this issue,

Tnx, Yotam


回答1:


Code should be

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

You should remove "new". For more information read this

Edit :-

Also you have added . in between two variable that should be ,

$username_Main_DB. $password_Main_DB replace this with $username_Main_DB,$password_Main_DB




回答2:


$con = mysqli_connect(..);

Remove the new keyword.



来源:https://stackoverflow.com/questions/27776955/wamp-php-error-fatal-error-class-mysqli-connect-not-found-in-c-wamp-www-fi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!