Foros del Web » Programando para Internet » PHP »

Tengo un problema con mysql

Estas en el tema de Tengo un problema con mysql en el foro de PHP en Foros del Web. Tengo un problema, ayer mi codigo funcionaba, pero ahora ya no sirve. me da este error: C骴igo PHP: 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  ...
  #1 (permalink)  
Antiguo 27/01/2011, 16:56
 
Fecha de Ingreso: mayo-2010
Mensajes: 185
Antig黣dad: 13 a駉s, 11 meses
Puntos: 2
Tengo un problema con mysql

Tengo un problema, ayer mi codigo funcionaba, pero ahora ya no sirve. me da este error:

C骴igo PHP:
You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near 's 09. Interludio 2 10. El Ni駉 De Los Cortes 11. Diario De Un Viajero (con F' at line 1 
Este es mi codigo:

C骴igo PHP:
<!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>
<title>Estacion Rap</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ie.css" />
<script type="text/javascript">var clear="images/clear.gif";</script>
<script type="text/javascript" src="unitpngfix.js"></script>
<![endif]-->
</head>
<body>
<?php
$conexion 
mysql_connect("sql201.byethost15.com""user""pass");
mysql_select_db("b15_5229524_estacion"$conexion);

$queEmp "SELECT * FROM Discos ORDER BY id DESC"
$resEmp mysql_query($queEmp$conexion) or die(mysql_error());
$totEmp mysql_num_rows($resEmp);
 if (
$totEmp0) {
    while (
$rowEmp mysql_fetch_assoc($resEmp)) {
 
    }
}
?>
<!-- BEGIN wrapper -->
<div id="wrapper">
  <!-- BEGIN header -->
   <?
include('arriba.php'); ?>
  <!-- END header -->
  <!-- BEGIN body -->
  <div id="body">
    <!-- BEGIN content -->
    <div id="content">
      <!-- begin post -->
      <div class="first post">
        <div class="r">
          
         
          
          
          <?php 

//coloca la coneccion correcta a mysql aqui 
$conexion mysql_connect("sql201.byethost15.com""user""pass");  
//selecciona la base de datos en la que quieres trabajar 
//y si esa es la unica base de datos que tienes, no vuelvas a abrir coneccion con mysql 
//ni a seleccionar otra vez la db 
mysql_select_db("b15_5229524_estacion"$conexion);  


$queEmp "SELECT * FROM Discos ORDER BY id DESC";   
$resEmp mysql_query($queEmp$conexion) or die(mysql_error());  
$totEmp mysql_num_rows($resEmp);  
 if (
$totEmp0) {  
    while (
$rowEmp mysql_fetch_assoc($resEmp)) {  
     
    
//while vacio... 
   
    
}  
}  
$titulo stripslashes($_POST["titulo"]);
$titulo strip_tags($titulo);
$canciones stripslashes($_POST["descripcion"]);
$canciones strip_tags($canciones);
$descarga stripslashes($_POST["descarga"]);
$descarga strip_tags($descarga);

 
//si esta coneccion es la misma que la de arriba, no hace falta incluirla 
 //y menos incluirla 3 o 4 veces  
//include('config.php'); //incluimos el config.php que contiene los datos de la conexi贸n a la db  
//include('config');  


if ( $_POST['titulo'] ) {
$state false;  
if (
preg_match("@image/(gif|jpg|jpeg|png|x-png|bmp)$@"$_FILES['archivo']['type'])){ 
if (
$_POST['action'] == "add" && $_FILES['archivo']['name'] != "") {   

//La subida de archivo dentro del condicional 
$ruta "./imagenes/" .time(). $_FILES['archivo']['name'];  
copy($_FILES['archivo']['tmp_name'], $ruta);  
echo 
"<b>La imagen subio correctamente</b>"
     }
     else{
    echo 
"Solo se pueden subir imagenes tipo .png,.gif,.jpg,.bmp,.jpeg";
    }
     
    
//VERIFICA A QUI: 
     
     
    //aqui conectas, denuevo pero al parecer a otra base de datos 
    
$conexion mysql_connect("sql201.byethost15.com""useer""pass");  
    
//pero a una tabla del mismo nombre 
    
mysql_select_db("b15_5229524_estacion"$conexion);  
    
//A $postear PUEDES DARLE UN VALOR MANUALMENTE PARA PROBAR Y QUE NO FALLE LA CONSULTA 
    
$postear $_SESSION[usuario];  
      
  
    
//session_start() debe estar precedido de la @ a esta altura del script 
    
@session_start();  

     if (
$titulo == "" or $canciones == "" or $descarga == "") {
     echo 
"Debes rellenar todos los campos";
     }
     else {  
    
$que "INSERT INTO Discos (titulo, descripcion, imagen, descarga, enviado) ";  
    
$que.= "VALUES ('".$titulo."', '".$canciones."', '".$ruta."', '".$descarga."', '".$_SESSION['idusuario']."')";  
    
$res mysql_query($que$conexion) or die(mysql_error());  
    
$state true;
    echo 
"Disco Agregado!";
    }  
     
     


  
}


}  


 
//SI INCLUDE() ES LA MISMA CONECCION A MYSQL QUE YA HICISTE NO ES NECESARIO 
//include('config.php'); //incluimos el config.php que contiene los datos de la conexi贸n a la db y la sesi贸n  

/* 
if($_SESSION[level] == 1 or $_SESSION[level] == 3){  
echo '';  
}else{  
Header("Location: index.php");  

*/  

?>  
<?
include('config.php'); //incluimos el config.php que contiene los datos de la conexi贸n a la db y la sesi贸n

if($_SESSION[level] == or $_SESSION[level] == or $_SESSION[level] ==4)
{
echo 
'';

}else{
Header("Location: index.php");
}
?>

<form name="formulario" form id="insertar" enctype="multipart/form-data" method="POST" action="">  
  <p align="left" class="Estilo1">A帽adir discos</p>
  <p align="left">&nbsp;</p>
  <p align="left">Titulo (Autor - Nombre del disco)</p>
  <p align="left"> 
    <input name="titulo" type="text" id="nombre" size="50" />
  </p>
  <p align="left"><br />  
    Canciones</p>
  <p align="left">
    <textarea name="descripcion" id="textarea" cols="45" rows="5"></textarea>
  </p>
  <p align="left"><br />  
    Imagen(Caratula Frontal)</p>
  <p align="left">
    <input type="file" name="archivo" id="archivo" />
  </p>
  <p align="left"><br />  
    Link de descarga(Empezando por http://)(Los archivos pueden estar subidos en cualquier host!)</p>
  <p align="left">
    <input type="text" name="descarga" id="textfield" />
    <br />
  </p>
  <p align="left"><br />  
      <input type="submit" name="Submit" value="Enviar disco" />
      <br />  
      <input type="hidden" name="action" value="add" />
      <br />  
            </p>
</form>  

<?php  



if ($state) {  
echo 
"<p /><em>Disco agregado</em></p>";  



?></div>
      </div>
      <!-- end post -->
      <!-- begin post -->
      <!-- end post -->
      <!-- begin post -->
      <!-- end post -->
    </div>
    <!-- END content -->
    <!-- BEGIN sidebar -->
     <?
include('menu.php'); ?>
    <!-- END sidebar -->
    <div class="break"></div>
  </div>
  <!-- END body -->
  <!-- BEGIN footer -->
  <?
include('abajo.php'); ?>
  <!-- END footer -->
</div>
<!-- END  -->
</body>
</html>
  #2 (permalink)  
Antiguo 27/01/2011, 17:15
Avatar de stingofung  
Fecha de Ingreso: enero-2011
Ubicaci髇: Mcbo
Mensajes: 52
Antig黣dad: 13 a駉s, 2 meses
Puntos: 1
Respuesta: Tengo un problema con mysql

Saludos "Arcana",

Puedes especificar exactamente cuando te da el error, si es al momento de cargar el formulario o al momento de guardar.

Etiquetas: mysql
Atenci髇: Est醩 leyendo un tema que no tiene actividad desde hace m醩 de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:57.