Jump to content

If someone has trouble with his or her query


fortnox007

Recommended Posts

Hi all, the last 15 minutes i wasted my time pulling my hair while looking at my php code. Of course I used mysqli_error() & mysqli_errno() to find out what was happening. I got something like this:

 

warning: mysqli_error() expects exactly 1 parameter, 0 given in /wicked/fatmonkeyseatbananas/zoo/index.php on line 12
That didnt really help me.

I also echoed out my query. Until I thought let's double check the field names I have in the database. They were also correct. And that's when I found out that it was in fact the property of a my ID field.

It was set as primary key, but not set to auto increment. Apparently each time a new row was inserted there was a conflict since the next row also had an id of 0. After I add auto increment it was all fixed.

 

So if anyone ever has this problem, hope this helps ::)

now it's time for a beer :P

 

btw. if anyone has a faster way of solving problems like this I love to hear it. ::)

Link to comment
Share on other sites

I used it like this:

$_firstname =  $_POST['firstname'];
                $_lastname  =  $_POST['lastname'];
                $_email     =  $_POST['email'];

                $query = "INSERT INTO email_list (first_name, last_name, email)".
                "VALUES('$_firstname', '$_lastname', '$_email')";
                echo $query;
                $result = mysqli_query($dbc,$query)or die(mysqli_error());
                echo 'query succes<br />';

-edit Ah I know see it.

 

I should have put $dbc inside mysqli_error() as a parameter. Thanks for the tip! I learned it all wrong from some internetsource. TY

     $result = mysqli_query($dbc,$query)or die(mysqli_error($dbc));

 

-edit2, i just recreated the problem and yes that error message is awesome  if used correct very handy : ) ty!! ::)  (this was my first time using it hehe )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.