tags:

views:

36

answers:

2

For some reason, i want to delete some of records in my table using php mysql query function. Here's what i've write

$sql = "delete from progress where first_date='2010-01-01' and last_date='2010-01-31';
delete from progress where first_date='2010-02-01' and last_date='2010-02-28';
delete from progress where first_date='2010-03-01' and last_date='2010-02-31';
delete from progress where first_date='2010-04-01' and last_date='2010-02-30';
delete from progress where first_date='2010-05-01' and last_date='2010-02-31';";

if(!mysql_query($sql)) echo "Error deleting records";

Thats exactly what i get, "Error deleting records". However when itrace it using mysql_error() , its no use after all. Anyone know how to handle this? Thank's before

+2  A: 

You cannot send more than one SQL query at a time when using mysql_query(). That is why it's failing and returning false.

BoltClock
that's what i've tought before. It's strange beacuse when i use phpmyadmin everithing looks fine
Miftah
I think it's because phpMyAdmin parses your SQL, splits statements by the given delimiter and runs `mysql_query()` once for each separate statement.
BoltClock
i will try again thank's before
Miftah
+4  A: 

mysql_query() can't execute multiple statements for security reasons.

use mysqli_multi_query() or call mysql_query() many times.

Naktibalda
yes i did using mysqli_multi_query but once i got error : 'command out of sync, you can't command now' or smiliar
Miftah
i will try again thank's before
Miftah