Solved

Insert attempt causes "Wrong parameter count for mysql_query"

Posted on 2004-08-16
4
257 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 300 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 150 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now