使用php在数据库中插入图像

时间:2014-01-02 15:00:09

标签: php

这是插入页面中的代码。当我运行代码时,它会在第14行给出undefine indext的错误。我想在数据库中上传图像并从数据库中检索。

<?php
$db_handle = mysql_connect("localhost","root","");
if (!$db_handle)
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("example");


    $first=$_POST['first'];
    $last=$_POST['last'];
    $hobbies=implode(',',$_POST['hobbies']);
    $study= implode(',', $_POST['study']);
    $image=$_FILES['image']['tmp_name'];
    //inserting data order
    $order = "INSERT INTO emp (F_name,L_name,Hobbies,Study,Image) VALUES('$first','$last','$hobbies','$study','$image')";

    //declare in the order variable
    $result = mysql_query($order);  //order executes
    if($result)
    {
        echo("<BR>Input data is succeed");
        echo "<BR>";
        echo "<a href='main.php'>Back to main page</a>";
    }
    else
    {
        echo("<BR>Input data is fail");
    }

mysql_close();
?>

0 个答案:

没有答案