0

大家好,我想**使用多个复选框并将它们的值插入数据库,但我收到此错误消息:'Warning: join() [function.join]: Invalid arguments passed in C';

下面是代码:

<?php
require_once('db_conn.php'); $cat=$_POST['cat'];

if(isset($_FILES['file_upload']) && isset($cat))
{
    $shuff=str_shuffle("ABD6565LSLFKDSAJFD");   

    $food = join(', ', $_POST['food']);     

    mkdir("upload/$shuff");

    $files=$_FILES['file_upload'];  

    for($x = 0; $x <count($files['name']); $x++)    
    {
        $name=$files['name'][$x];    
        $tmp_name=$files['tmp_name'][$x];

        if(move_uploaded_file($tmp_name, "upload/$shuff/".$name))
        {
            $query="INSERT INTO image(mid, cid, name, food, path) VALUES('', '$cat', '$name', '$food', 'upload/$shuff/$name')";
            mysql_query($query);
            echo 'The file '.$name. ' uploaded successfully'. '<br \>';
        }
        else
        {
            echo 'uploading failed';
        }
    }
}
?>
4

1 回答 1

0

尝试使用内爆而不是加入:

if( !empty($_POST['food']) AND is_array($_POST['food']) ) {    
   $food = implode(', ', $_POST['food']); 
}
else {
  $food = "";
}
于 2013-03-25T04:31:02.773 回答