php - 如何将图像数据从一张表移动到另一张表?

标签 php mysql sql

<?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 我能够将所有数据从 tipuranibasti 移动到 puranibasti 表,除了图像任何人都可以帮忙

最佳答案

也许你可以在单个sql语句中插入值而不是选择+插入:

if(
   @mysql_query("     
      insert into puranibasti  
      select '', name, date, msg, image 
      from tipuranibasti where id = $id"
  ")

关于php - 如何将图像数据从一张表移动到另一张表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8631758/

相关文章:

php - 更新两个不同表中两个不同列的查询-MySQL

mysql - mysql如何合并列的值

sql - 如何使用 SQL 计算给定轨迹中每条边的行进次数?

javascript - 金融应用程序的外汇汇率

php - array_unique 是否开始新的数组索引号?

mysql - laravel5.4 中 undefined variable

SQL Server - 缺少 NATURAL JOIN/x JOIN y USING(字段)

sql - 选择非空列

php - 在 if 语句中使用一个等号

PHP - 从基于值名称组合类似值的 php 数组构建多级 HTML 菜单