Click here to Skip to main content
15,891,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\wamp64\www\PhpProject3\login_submit.php on line 6
Call Stack
#	Time	Memory	Function	Location
1	0.0011	408400	{main}( )	...\login_submit.php:0
2	0.0019	409056	mysqli_error ( )	...\login_submit.php:6
<pre>
<?php 
         require 'includes/common.php';
        if (isset($_SESSION['email'])) {
          header('location: products.php');
             }
    /* connection*/
    $conn = mysqli_connect_error("localhost", "root","","ecommerce")or die(mysqli_error($conn)); echo"connected";

         $email= mysqli_real_escape_string($conn,$_POST['email']);
        $first_name=mysqli_real_escape_string($conn,$_POST['email']);`enter code here`
        $last_name=mysqli_real_escape_string($conn,$_POST['email']);
        $phone=mysqli_real_escape_string($conn,$_POST['email']);
        $login_submit_query ="insert into users(email,first_name,last_name,phone) 
          values('email','first_name','last_name',phone)";
          die($login_submit_query);

         $result = mysqli_query($conn,$login_submit_query)or die ('Error:' . mysqli_error($conn));
           echo 'user successfully inserted';

 ?>


What I have tried:

changing ports
almost everything on google
Posted
Updated 24-May-21 19:47pm
v2
Comments
SeanChupas 24-May-21 11:23am    
Your code to call MySql is not correct. Looks like something is null.
Richard MacCutchan 25-May-21 3:39am    
See my updated solution below.
Richard Deeming 25-May-21 4:34am    
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
PHP: SQL Injection - Manual[^]

Strangely enough, this is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.

So when your code throws an error and we have no access to yoru code, how do your expect us to be able to tell you how to solve it? That's like asking me to proofread your resume, but refusing to let me have a copy incase I see something you don't want me to know ...

So all we can do is talk generally.
Start by looking at the error message:
Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\wamp64\www\PhpProject3\login_submit.php on line 6
This tells you a lot of information:
1) What problem it found. In this case you are calling a function that expects at least one parameter, and that parameter can't be null.
2) It's in your file "C:\wamp64\www\PhpProject3\login_submit.php"
3) It's line 6 that gives the problem.

So open that file in the editor, and look at line 6. What are you calling? What are you passing it? Where does that parameter get given a value?

Most probably, you are using a variable that you haven't assigned a value yet - by since we can't see any of your code, we can't tell...
 
Share this answer
 
And it is allexpalined in the documentation. See Mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in[^].

[edit]
PHP
$conn = mysqli_connect_error("localhost", "root","","ecommerce")or die(mysqli_error($conn));

If mysqli_connect_error fails it will return null, so the call to mysqli_error will fail because you are passing it a null value. You need to do proper checks on the return values from system/API calls.
[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900