要求参数1为mysqli

要求参数1为mysqli

本文介绍了获取错误警告:mysqli_query()要求参数1为mysqli,第10行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

register.php

 <?php  
if(isset($ _ POST) [ register])){
$ firstname = $ _ POST [ first_name];
$ middlename = $ _ POST [ middle_name];
$ surname = $ _ POST [ surname];
$ username = $ _ POST [ username];
$ email = $ _ POST [ email];
$ password = md5($ _ POST [ password_1]);
$ query_reg = INSERT INTO tbl_users VALUES('','$ firstname','$ middlename', '$姓', '用户名$', '$电子邮件', '$口令', '');
$ result_obj = mysqli_query($ conn,$ query_reg);
if($ result_obj){
?>
<? php
$ db_host = localhost ;
$ db_username = root;
$ db_password = ;
$ db_name = cive_orsp;
try {
$ conn = new PDO( mysql:host = $ db_host; dbname = $ db_name,$ db_username,$ db_password);
$ conn-> setAttribute(PDO :: ATTR_ERRMODE,PDO :: ERRMODE_EXCEPTION);
echo Succefully Connected;
} catch(PDOException $ e){
die( 数据库异常 。$ E->的getMessage());
}

?>





我尝试了什么:



i试图将我的注册页面连接到数据库

解决方案




register.php

<?php
if(isset($_POST["register"])){
    $firstname=$_POST["first_name"];
    $middlename=$_POST["middle_name"];
    $surname=$_POST["surname"];
    $username=$_POST["username"];
    $email=$_POST["email"];
    $password=md5($_POST["password_1"]);
    $query_reg="INSERT INTO tbl_users VALUES('','$firstname','$middlename','$surname','$username','$email','$password','')";
    $result_obj=mysqli_query($conn,$query_reg);
    if($result_obj){
?>
<?php
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "cive_orsp";
try{
    $conn = new PDO("mysql:host=$db_host;dbname=$db_name", $db_username,$db_password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Succefully Connected";
}catch(PDOException $e){
    die("Database Exception ".$e->getMessage());
}

?>



What I have tried:

i was trying to connect my registration page to database

解决方案




这篇关于获取错误警告:mysqli_query()要求参数1为mysqli,第10行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 13:39