2014-10-13 2 views
0

이 스크립트는 대상 데이터베이스에 연결하고 대상 데이터베이스에있는 ligne을 변환하여 대상 데이터베이스에 windows-1256 인코딩의 모든 ligne를 표시합니다. 데이터베이스하지만 그것은 단지 첫 맞추을 삽입하고 말 : 경고 : mysqli_fetch_array()을 예상 매개 변수 (1) mysqli_result되는, 부울 C에 주어진 : \ WAMP \ www가 \ 업데이트-부터 TXT \ conv.php 라인 (17)에mysql은 인코딩을 변환하고 데이터베이스에서 데이터베이스에 삽입합니다

<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> 
+0

쿼리 F를 해결 어딘가에 오류가 있습니다. –

+0

17 번 줄이 15 번째 줄에있는 쿼리를 확인해야하는 것보다 17 번째 줄을 보는 것이므로 테이블과 열 이름에 백틱을 사용하고 때로는 쿼리가 실패 할 수 있습니다. –

답변

0

이 문제를

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

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