This code do a transaction with all queries stored in $in. for example $in = "Query1; Query2; Query3;"
When one of them fails, it is rolled back but has no effect and the queries that had no errors are inserted into the database
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('ERR');
}
mysql_select_db('db445123652');
mysql_query("START TRANSACTION");
$strlen = strlen( $in);
$ini = 0;
for( $i = 0; $i <= $strlen; $i++ ) {
$char = substr( $in, $i, 1 );
if($char == ';' )
{
$resul = mysql_query(substr( $in, $ini, $i ));
if(!$resul)
{
echo mysql_error();
mysql_query("ROLLBACK");
echo 'Rollback';
break;
}
else{
$ini = $i + 1;
}
}
}
if($i==($strlen+1) && $resul)
{
echo 'OK';
mysql_query("COMMIT");
}
The database is in a 1&1 host and I acces through phpmyadmin.
check for your database to table engine, if it is set to InnoDb or not.
there is difference between MyISAM and Innodb refer http://www.rackspace.com/knowledge_center/article/mysql-engines-myisam-vs-innodb