fortnox007 Posted September 22, 2010 Share Posted September 22, 2010 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 btw. if anyone has a faster way of solving problems like this I love to hear it. Link to comment https://forums.phpfreaks.com/topic/214144-if-someone-has-trouble-with-his-or-her-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2010 Share Posted September 22, 2010 The error message you posted is because mysqli_error() expects the mysqli link as a parameter. Had you used the mysqli_error() function correctly, the resulting msyql error would have told you the query was failing due to a duplicate index value. Link to comment https://forums.phpfreaks.com/topic/214144-if-someone-has-trouble-with-his-or-her-query/#findComment-1114296 Share on other sites More sharing options...
fortnox007 Posted September 22, 2010 Author Share Posted September 22, 2010 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 https://forums.phpfreaks.com/topic/214144-if-someone-has-trouble-with-his-or-her-query/#findComment-1114298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.