mensagem "Column 'arquivo' cannot be null" mesmo após
Pessoal estou apenas por aprendizagem, tentando fazer um sistema de múltiplo upload de arquivos que além de fazer o upload ele inseri o nome dos arquivos no banco de dados mysql, o script está fazendo upload e inserindo no banco de dados normalmente e mesmo assim exibe a mensagem "Column 'arquivo' cannot be null", segue abaixo o script:
<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if(isset($_POST['botao'])) {
$arquivo = $_FILES['arquivo']['tmp_name'];
$count = count($arquivo);
for($i=0; i < $count; $i++) {
$updir = "../arquivos/cursos/";
$insertSQL = sprintf("INSERT INTO arquivos (arquivo) VALUES (%s)",
GetSQLValueString($_FILES['arquivo']['name'][$i], "text"));
mysql_select_db($database_conexao, $conexao);
$Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error());
$mover = move_uploaded_file($_FILES['arquivo']['tmp_name'][$i], $updir .$_FILES['arquivo']['name'][$i]);
}
if($Result1) {
echo "SUCESSO";
} else {
echo "FALHA";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">
<label>
<input type="file" name="arquivo[]" multiple="multiple" /> </br>
<input type="submit" name="botao" value="Enviar" />
</label>
</form>
</body>
</html>
Se alguém puder dar uma força eu agradeço.
Discussão (1)
Carregando comentários...