Olá! Tenho um script de upload (ver abaixo) que grava o nome da imagem no bd e carrega a foto para um diretório. Meu script tá dando o seguinte erro:
Unknown table 'nomedaimagem' in field list
A expressão "nomedaimagem" acima representa o nome da imagem que eu tentei carregar. Coloco o script abaixo e gostaria que alguém pudesse me dizer o porque do erro acima. Obrigado!!
mysql_select_db($database_noticias, $noticias); $query_rsFotos = "SELECT * FROM tbFotos"; $rsFotos = mysql_query($query_rsFotos, $noticias) or die(mysql_error()); $row_rsFotos = mysql_fetch_assoc($rsFotos); $totalRows_rsFotos = mysql_num_rows($rsFotos);
mysql_select_db($database_noticias, $noticias); $query_rsEditorias = "SELECT * FROM tbEditorias ORDER BY editoria ASC"; $rsEditorias = mysql_query($query_rsEditorias, $noticias) or die(mysql_error()); $row_rsEditorias = mysql_fetch_assoc($rsEditorias); $totalRows_rsEditorias = mysql_num_rows($rsEditorias);
mysql_select_db($database_noticias, $noticias); $query_rsNoticias = "SELECT idNoticia, titulo FROM tbNoticias ORDER BY idNoticia DESC"; $rsNoticias = mysql_query($query_rsNoticias, $noticias) or die(mysql_error()); $row_rsNoticias = mysql_fetch_assoc($rsNoticias); $totalRows_rsNoticias = mysql_num_rows($rsNoticias);
Pergunta
©JOÃO GABRIEL MARQUES
Olá! Tenho um script de upload (ver abaixo) que grava o nome da imagem no bd e carrega a foto para um diretório. Meu script tá dando o seguinte erro:
Unknown table 'nomedaimagem' in field list
A expressão "nomedaimagem" acima representa o nome da imagem que eu tentei carregar. Coloco o script abaixo e gostaria que alguém pudesse me dizer o porque do erro acima. Obrigado!!
<?php require_once('../../../Connections/noticias.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "uploadFotos")) {
$arquivo = $_FILES['path'];
$arquivo_nome = $arquivo['name'];
$insertSQL = sprintf("INSERT INTO tbFotos (idFoto, idNoticia, legenda, creditos, path) VALUES (%s, %s, %s, %s, $arquivo_nome)",
GetSQLValueString($HTTP_POST_VARS['idFoto'], "int"),
GetSQLValueString($HTTP_POST_VARS['idNoticia'], "int"),
GetSQLValueString($HTTP_POST_VARS['legenda'], "text"),
GetSQLValueString($HTTP_POST_VARS['creditos'], "text"));
//GetSQLValueString($HTTP_POST_VARS[$arquivo_nome], "text"));
set_time_limit(0);
$editoria = $HTTP_POST_VARS['editoria'];
$diretorio = "../../$editoria/imagens";
$id_arquivo = "path";
$nome_arquivo = $_FILES[$id_arquivo]['name'];
$arquivo_temporario = $_FILES[$id_arquivo]['tmp_name'];
move_uploaded_file($arquivo_temporario, "$diretorio/$nome_arquivo");
mysql_select_db($database_noticias, $noticias);
$Result1 = mysql_query($insertSQL, $noticias) or die(mysql_error());
$insertGoTo = "uploadImagemOk.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_noticias, $noticias);
$query_rsFotos = "SELECT * FROM tbFotos";
$rsFotos = mysql_query($query_rsFotos, $noticias) or die(mysql_error());
$row_rsFotos = mysql_fetch_assoc($rsFotos);
$totalRows_rsFotos = mysql_num_rows($rsFotos);
mysql_select_db($database_noticias, $noticias);
$query_rsEditorias = "SELECT * FROM tbEditorias ORDER BY editoria ASC";
$rsEditorias = mysql_query($query_rsEditorias, $noticias) or die(mysql_error());
$row_rsEditorias = mysql_fetch_assoc($rsEditorias);
$totalRows_rsEditorias = mysql_num_rows($rsEditorias);
mysql_select_db($database_noticias, $noticias);
$query_rsNoticias = "SELECT idNoticia, titulo FROM tbNoticias ORDER BY idNoticia DESC";
$rsNoticias = mysql_query($query_rsNoticias, $noticias) or die(mysql_error());
$row_rsNoticias = mysql_fetch_assoc($rsNoticias);
$totalRows_rsNoticias = mysql_num_rows($rsNoticias);
?>[/codebox]
Link para o comentário
Compartilhar em outros sites
4 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.