Php mysql将编码和插入从数据库转换到数据库

Php mysql将编码和插入从数据库转换到数据库,php,Php,此脚本应在母数据库中显示windows-1256编码中的所有对齐方式,然后将其连接到目标数据库,并将该对齐方式从母数据库转换并插入到目标数据库中,但它只插入第一个对齐方式并说: 警告:mysqli_fetch_array()希望参数1是mysqli_结果,布尔值在第17行的C:\wamp\www\updatefrom txt\conv.php中给出 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta co

此脚本应在母数据库中显示windows-1256编码中的所有对齐方式,然后将其连接到目标数据库,并将该对齐方式从母数据库转换并插入到目标数据库中,但它只插入第一个对齐方式并说: 警告:mysqli_fetch_array()希望参数1是mysqli_结果,布尔值在第17行的C:\wamp\www\updatefrom txt\conv.php中给出

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
<h1>table_mother</h1>
id ||||||||||| 3onwan<br>
<?php
$con=mysqli_connect("localhost","root","","labase_mother");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM source");

while($row = mysqli_fetch_array($result)) {
echo $row['ident'] . " |" . $row['titre'];
$titre_convi= $row['titre'];
$identifient= $row['ident'];

//test convert
//convertire
$convert = iconv('windows-1256', 'utf-8', $titre_convi );
//connection
$con2 = mysqli_connect("localhost","root","","labase_target");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//insertion
$result = mysqli_query($con2,"insert into target(ident1, titre1) values ('$identifient',  '$convert')")or die(mysqli_error($con2));

//fin test convert

echo "<br>";
}

mysqli_close($con);
mysqli_close($con2);
?>
<h2>table_target</h2>
id ||||||||||| 3onwan<br>
<!--resultat-->
<?php
$con=mysqli_connect("localhost","root","","labase_target");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM target");

while($row = mysqli_fetch_array($result)) {
echo $row['ident1'] . " |" . $row['titre1'];
echo "<br>";
}

mysqli_close($con);
?>
</body>
</html>

母亲
id|||||||||3onwan

这就解决了问题

$convert= str_replace("'", "", $convert);

$result1 = mysqli_query($con2,"insert into target(ident1, titre1) values ('".$identifient."', '$convert')")or die(mysqli_error($con2));

您的查询在某个地方失败,这就是错误所在。正如我看到的,第17行是您的第一个查询,您应该检查第15行的查询,在表名和列名中使用反勾号,有时如果没有它们,查询可能会失败。