Solved

Insert attempt causes "Wrong parameter count for mysql_query"

Posted on 2004-08-16
4
258 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Simple PHP/mySQL Query 3 51
simplest php form 3 63
<? versus <?php 5 37
Access Object's Property 9 22
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

895 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

17 Experts available now in Live!

Get 1:1 Help Now