2011-12-25 4 views
0

한 테이블에서 'tipuranibasti'(한 열은 이미지 용 BLOB 타입) 행을 'puranibasti'에 복사하는 방법은 무엇입니까? 내 코드를 사용하여 모든 필드는 blob 필드 [이미지 필드]를 제외하고 puranibasti로 복사되었습니다.한 테이블에서 다른 테이블로 행을 복사하는 방법

blob 필드는 데이터베이스의 puranibasti 테이블에서 [BLOB - 0B]처럼 보입니다.

<?php 
include ("connect.php"); 
[email protected]($_GET['id']); 
[email protected]_query("select * from tipuranibasti where id = $id"); 
[email protected]_fetch_assoc($image); 

[email protected]$image_row['name']; 
[email protected]$image_row['date']; 
[email protected]$image_row['msg']; 
$image=addslashes(@file_get_contents($image_row['image'])); 


if(@mysql_query("insert into puranibasti values('','$name','$date','$msg','$image')")) 
{ 
echo "image has been inserted successfully"; 
} else 
{ 
echo "problem inserting the image"; 
} 
?> 

답변

2

시도한 코드는 무엇입니까? 나는 말하고 싶습니다

UPDATE A INNER JOIN B ON A.some_id=B.some_id SET B.blobfield = A.blobfield 

업데이트 : 코드를보고, 이것은 물론 변수의 내용을 가지고 있기 때문에 이것은 다른 상황입니다. 당신은 그 것을 버리고 후에 위에 제안한 업데이트를 할 것입니다. 또는 addslashes없이 시도하십시오. 또한 문자열을 연결하는 대신 적절한 데이터베이스 변수를 사용해보십시오. BLOB 필드의 내용이 바이너리이기 때문에 문자열에 넣을 때 추한 일이 일어난다는 것을 알 수 있습니다.

+0

답장을 보내 주셔서 감사합니다 ... 작동하는 다른 쿼리를 사용했습니다 : puranibasti select '', name, date, msg, tipuranibasti의 이미지 ID = $ id – tabi

관련 문제