我似乎无法将值上传到数据库表中

时间:2013-12-15 01:36:31

标签: php

我似乎无法将值上传到数据库表中。它一直给我这个错误:

  

上传错误,请再试一次。

这是我的代码:

if(isset($_FILES['musicFile']['name']))
{
    $uploaddir = "/accounts/groups/MDM2013.02/public_html/TPFinal/music/";
    $uploadfile = basename($_FILES['musicFile']['name']);
    $uploadpath = $uploaddir . $uploadfile;
    //echo substr($uploadfile, -3);
    //echo $uploaddir;
    //echo $uploadpath;
    //var_dump($uploadfile);
    if((strcasecmp(substr($uploadfile, -3), "mp3") == 0))//||(strcasecmp(substr($uploadfile, -3, 3), "wav") == 0))
    {
        if(!is_file($uploadpath))
        { 
            if (move_uploaded_file($_FILES['musicFile']['tmp_name'],$uploadpath)) 
            {
                if((strcasecmp($type,"audio/mp3") == 0))// || (strcasecmp($type, "music/wav")== 0))
                {
                    echo "File of a valid type ($type), and was stored as $uploadfile<br/>\n";
                    $data = $_POST['musicFile']; $art = $_POST['ArtistName']; $title = $_POST['MusicTitle'];
                    $sql = "INSERT INTO Music(UserName,MusicName,MusicType, Artist, Data) VALUES ('$username','$title','$type', '$art', '$data')";
                    $result= mysql_query($sql);
                    if($result)
                    {
                        if(mysql_affected_rows() == 1)
                        {
                        echo "Music inserted into Database, with ID = ", 
                        mysql_insert_id();
                        }
                    }
                }else{echo "Failed mime-checking <br/>"; unlink($uploadpath);}

            }else{echo "Upload Error, please try again! <BR/> \n";}

        }else echo "File already exists <br/>\n";}

    else echo "Only MP3 files are acceptable ($uploadfile) <br/>\n";}

include_once ("db_close.php");
?>

1 个答案:

答案 0 :(得分:0)

您实际上可以检查您获得的具体错误。请尝试检查错误here