Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert attempt causes "Wrong parameter count for mysql_query"

Posted on 2004-08-16
4
Medium Priority
?
265 Views
Last Modified: 2013-12-12
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!
0
Comment
Question by:hankknight
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
AlanJDM earned 1200 total points
ID: 11814578
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
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 600 total points
ID: 11814589
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 11814635
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
 
LVL 16

Author Comment

by:hankknight
ID: 11814750
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question