Solved

Insert attempt causes "Wrong parameter count for mysql_query"

Posted on 2004-08-16
4
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
curl parse data from site 20 64
Group By Function Required in PDF Output 21 65
How can I use javascript variable in mysql query 21 38
php non-object 7 26
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 look for a specific file type in a local or remote server directory using PHP.

734 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