Page 1 of 1
php and mysql related firefox problem
Posted: Fri Aug 12, 2011 2:04 am
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.
Re: php and mysql related firefox problem
Posted: Fri Aug 12, 2011 12:19 pm
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.
Re: php and mysql related firefox problem
Posted: Fri Aug 12, 2011 12:29 pm
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.
Re: php and mysql related firefox problem
Posted: Fri Aug 12, 2011 5:50 pm
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)