Insert attempt causes "Wrong parameter count for mysql_query"

Hello.

I am trying to add a new set of data to a table and am getting the following error:

           Warning: Wrong parameter count for mysql_query() in script.php on line 2


Here is my code:

           $insert_query = "INSERT INTO MY_db (ID, 1, 2, 3, 4, 5,) VALUES ($1, $2, $3, $4, $5)";
           mysql_query($insert_query) or die("Insert Query Error : " . mysql_query());

The field ID is thre primary field and is auto-numbered.

Thanks!
LVL 16
hankknightAsked:
Who is Participating?
 
AlanJDMConnect With a Mentor Commented:
mysql_query($insert_query) or die("Insert Query Error : " . mysql_query());

You are calling mysql_query instead of mysql_error at end of this line.


Alan
0
 
Diablo84Connect With a Mentor Commented:
your trying to insert 5 vaues into 6 fields



           $insert_query = "INSERT INTO MY_db (ID, 1, 2, 3, 4, 5,) VALUES ('', $1, $2, $3, $4, $5)";
           mysql_query($insert_query) or die("Insert Query Error : " . mysql_query());


or using NULL should work

           $insert_query = "INSERT INTO MY_db (ID, 1, 2, 3, 4, 5,) VALUES (NULL, $1, $2, $3, $4, $5)";
           mysql_query($insert_query) or die("Insert Query Error : " . mysql_query());
0
 
AlanJDMCommented:
Sorry Diablo... but no, what you descripe is not causing the warning he reported.

"Warning: Wrong parameter count for mysql_query() in script.php on line 2"

What you pointed out is still an issue that the poster needs to be aware of, just not the one casing the warning.


Alan
0
 
hankknightAuthor Commented:
Thanks for the team work.  It was the mysql_query instead of mysql_error that was causing the issue.  Once I fixed that I quickly identified the issue addressed in the next comment.
0
All Courses

From novice to tech pro — start learning today.