简体   繁体   中英

How can I move image data from one table to another?

<?php
include ("connect.php");
$id=@addslashes($_GET['id']);
$image=@mysql_query("select * from tipuranibasti where id = $id");
$image_row=@mysql_fetch_assoc($image);  
$name=@$image_row['name'];
$date=@$image_row['date']; 
$msg=@$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";
}
?>

1 im able to move all data to table puranibasti from tipuranibasti except image can anyone please help

Perhaps you can insert value in a single sql sentence instead select + insert:

if(
   @mysql_query("     
      insert into puranibasti  
      select '', name, date, msg, image 
      from tipuranibasti where id = $id"
  ")
INSERT INTO target (id, name, date, msg, image)
SELECT '', name, date, msg, image FROM source
WHERE source.id = $id

This approach prevents you from having to convert sql values to php and then back from php to sql.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM