Well, I try to explain this, but please apologize for my English.
I have a script that unloads the entire database into an SQL file, and then another script breaks the rows and executes them to delete, create and insert data. The problem is that some lines are "clipped". It simply inserts the string until it reaches the first special character, for example:
For the string:
"Pantalon azul marino de Poliéster con cinta blanca bordada con el nombre de la institución en uno de sus costados."
just paste:
"Pantalon azul marino de Poli"
An error does not occur. But this only happens with a script, but when I run the queries manually and import the SQL file into phpMyAdmin, everything works. By the way, everything is installed on utf8.
I have no ideas, any help would be greatly appreciated.
include ('../core/connection.inc.php');
$conn = dbConnect('admin');
$conn->query("SET NAMES 'utf8'");
$conn->set_charset("utf8");
$type = 0;
$templine = '';
$lines = file('db-backup.sql');
$correct = 0;
$failed = 0;
foreach ($lines as $line){
if (substr($line, 0, 2) == '--' || $line == '')
continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';'){
$templine = str_replace("latin1","utf8",$templine);
$templine = trim($templine);
$conn->query($templine);
$errno = $conn->errno;
$error = $conn->error;
if($conn->affected_rows > 0){
echo "OK: (".$templine.")<br/>";
$correct++;
} else {
echo "Failed: (".$templine.")<br/>";
echo " Errno: ".$errno." <br/>";
echo " Error: ".$error." <br/>";
$failed++;
}
$templine = '';
}
}
source
share