Ver Mensaje Individual
  #6 (permalink)  
Antiguo 10/05/2015, 12:31
camilomascarell1987
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 11 años, 1 mes
Puntos: 0
Respuesta: formulario subir multiples de imagenes con php mysql

Mysql es muy problemas paso?
Código HTML:
Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /Applications/XAMPP/xamppfiles/htdocs/digitalflash/admin/foto_nuevo.php on line 83
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 ')' at line 1
Código 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 "'" "INSERT";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "INSERT";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "INSERT";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "INSERT";
      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"] == "fotonuevo")) {
  
$insertSQL sprintf("INSERT INTO foto (imagenes) VALUES (%s)",
                       
GetSQLValueString($_FILES['imagenes']['name'], "text"));
                       
if (isset(
$_FILES['imagenes'])){
    
// Hacemos una condicion en la que solo permitiremos que se suban imagenes y que sean menores a 20 KB
    
if ((($_FILES["imagenes"]["type"] == "image/gif") || 
    (
$_FILES["imagenes"]["type"] == "image/jpeg") || 
    (
$_FILES["imagenes"]["type"] == "image/png") ||
    (
$_FILES["imagenes"]["type"] == "image/pjpeg")) && 
    (
$_FILES["imagenes"]["size"] < 2000000)) {
    
    
//Si es que hubo un error en la subida, mostrarlo, de la variable $_FILES podemos extraer el valor de [error], que almacena un valor booleano (1 o 0).
      
if ($_FILES["imagenes"]["error"] > 0) {
        echo 
$_FILES["imagenes"]["error"] . "<br />";
      } else {
          
// Si no hubo ningun error, hacemos otra condicion para asegurarnos que el archivo no sea repetido
          
if (file_exists("../fotografico/foto/" $_FILES["imagenes"]["name"])) {
            echo 
$_FILES["imagenes"]["name"] . " ya existe. ";
          } else {
           
// Si no es un archivo repetido y no hubo ningun error, procedemos a subir a la carpeta /archivos, seguido de eso mostramos la imagen subida
            
move_uploaded_file($_FILES["imagenes"]["tmp_name"],
            
"../fotografico/foto/" $_FILES["imagenes"]["name"]);
          }
      }
    } else {
        
// Si el usuario intenta subir algo que no es una imagen o una imagen que pesa mas de 20 KB mostramos este mensaje
    
}
}

  
mysql_select_db($database_digitalflash$digitalflash);
  
$Result1 mysql_query($insertSQL$digitalflash) or die(mysql_error());

  
$insertGoTo "foto_index.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_digitalflash$digitalflash);
$query_admin "SELECT * FROM `admin`";
$admin mysql_query($query_admin$digitalflash) or die(mysql_error());
$row_admin mysql_fetch_assoc($admin);
$totalRows_admin mysql_num_rows($admin);

mysql_select_db($database_digitalflash$digitalflash);
$query_fotonuevo "SELECT * FROM foto";
$fotonuevo mysql_query($query_fotonuevo$digitalflash) or die(mysql_error());
$row_fotonuevo mysql_fetch_assoc($fotonuevo);
$totalRows_fotonuevo mysql_num_rows($fotonuevo);
?>