Formulário de envio de arquivo
Pessoal,
Estou com um problemas no formulário PHP de envio de arquivos, porque não consigo enviá-lo e me mostra um erro assim:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '1149')' at line 1
O código fonte da página é este:
admin.php
<?php require_once('Connections/conn_uni.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$arquivo = $_FILES["arquivo_usuario"];
$insertSQL = sprintf("INSERT INTO arquivos_clientes (arquivo_usuario, cliente_id, nome_cliente) VALUES ('$arquivo', %s, %s)",
GetSQLValueString($_POST['arquivo_usuario'], "file"),
GetSQLValueString($_POST['cliente_id'], "text"),
GetSQLValueString($_POST['nome_cliente'], "text"));
mysql_select_db($database_conn_uni, $conn_uni);
$Result1 = mysql_query($insertSQL, $conn_uni) or die(mysql_error());
$insertGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conn_uni, $conn_uni);
$query_Rsarq = "SELECT * FROM arquivos_clientes";
$Rsarq = mysql_query($query_Rsarq, $conn_uni) or die(mysql_error());
$row_Rsarq = mysql_fetch_assoc($Rsarq);
$totalRows_Rsarq = mysql_num_rows($Rsarq);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)
<html xmlns="[http://www.w3.org/1999/xhtml">](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 action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Arquivo_usuario:</td>
<td><input name="arquivo_usuario" type="file" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Cliente_id:</td>
<td><input type="text" name="cliente_id" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nome_cliente:</td>
<td><input type="text" name="nome_cliente" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Rsarq);
?>
Obrigado.
Rogério Oliveira.
Discussão (13)
Carregando comentários...