php and mysql related firefox problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
doitnow1147
Forum Newbie
Posts: 1
Joined: Fri Aug 12, 2011 1:57 am

php and mysql related firefox problem

Post by doitnow1147 »

i don't know why my firefox browser executing mysql query two times. and this is happening only with firefox. i have tested the code with chrome and opera and its working fine. I have tested simple php code . this one

Code: Select all


mysql_query("insert into test('1','12345')");
 


 
just this code and i am facing the same problem.
it inserting the two times data into the test table.
genix2011
Forum Commoner
Posts: 74
Joined: Tue Aug 02, 2011 4:00 pm

Re: php and mysql related firefox problem

Post by genix2011 »

What does this have to do with the browser?

Your Mysql-Query is wrong. It must be:

Code: Select all

mysql_query("insert into test values('1','12345')");
You forgot the "values" keyword in your insert statement.

I would also recommend using the "or die("Error: " . mysql_error())" statement after your mysql_query for quick debugging, to see where exactly your error is.

With your code it would look like this:

Code: Select all

 mysql_query("insert into test values ('1','12345')") or die("Error: " . mysql_error());
Greets.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: php and mysql related firefox problem

Post by social_experiment »

Code: Select all

$qry = "INSERT INTO table (field1, field2) VALUES (value1, value2)";
The query should contain the field names where the data is supposed to go aswell. Good point about adding mysql_error() for debugging purposes, it's very useful.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: php and mysql related firefox problem

Post by twinedev »

You say just firefox does it twice, and since the browser has no effect on SQL statements themselves, so we would need to see more code than just that line (while the above suggestions are still very valid and good suggestions for that line)
Post Reply