Comunidad de diseño web y desarrollo en internet online

[AYUDA] Insertar valores en una base de datos

Citar            
MensajeEscrito el 12 Oct 2008 03:57 am
Lo he hacho varias veces y este error también apareció varias veces y lo he solucionado, pero esta vez no encuentro solución.

Me aparece el siguiente error:

MauXXI escribió:

Problemas en el select porque: 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 'fulltext,state,sectionid,mask,catid,created,created_by,modified,modified_by,chec' at line 1


El código que uso es:

Código :

<?php

$title=$_REQUEST['title'];
$alias=$_REQUEST['alias'];
$numvid=$_REQUEST['numvid'];
$carpvid=$_REQUEST['carpvid'];
$intro=$_REQUEST['desc'];
$introtext='<div align="center">
<table width="506" cellspacing="0" cellpadding="0" border="0" align="center" style="background-image: url(http://www.zonasafaritv.com/images/stories/fondovideo.jpg); height: 140px;">
    <tbody>
        <tr>
            <td rowspan="2">
            <p><img height="120" width="150" border="0" alt="" src="http://www.mauxxi.com.ar/videos/'.$carpvid.'/'.$numvid.'.jpg" /></p>
            </td>
            <td valign="top" align="left" style="width: 100%;">
            <p> </p>
            <p>'.$intro.'</p>
            </td>
        </tr>
        <tr>
            <td valign="middle" align="right" style="height: 38px;"><a href="index.php?option=com_content&amp;view=article&amp;id=90:publiciteaqui"><img border="0" alt="" src="images/stories/anunciovideo.jpg" /></a></td>
        </tr>
    </tbody>
</table>
';
$fulltext='<p align="center"> </p>
<p align="center">{googleAds}&lt;script type="text/javascript"&gt;&lt;!--<br />
google_ad_client = "pub-4919012334189769";<br />
/* Zona Safari 1 */<br />
google_ad_slot = "7870246544";<br />
google_ad_width = 468;<br />
google_ad_height = 60;<br />
//--&gt;<br />
&lt;/script&gt;<br />
&lt;script type="text/javascript"<br />
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;<br />
&lt;/script&gt;{/googleAds}</p>
<p align="center"> </p>
<p align="center">{iframe width="340" height="265" align="middle"}http://www.mauxxi.com.ar/videos/'.$carpvid.'/'.$numvid.'.html{/iframe}</p>
</div>';
$state=1;
$sectionid=2;
$mask=0;
$catid=$_REQUEST['catid'];
$created=date ('Y-m-d H:i:s');
$created_by=62;
$modified=date ('Y-m-d H:i:s');
$modified_by=62;
$checked_out=0;
$checked_out_time='0000-00-00 00:00:00';
$publish_up=date ('Y-m-d H:i:s');
$publish_down='0000-00-00 00:00:00';
$attribs='show_title=1
link_titles=1
show_intro=
show_section=
link_section=
show_category=
link_category=
show_vote=
show_author=
show_create_date=
show_modify_date=
show_pdf_icon=
show_print_icon=
show_email_icon=
language=
keyref=
readmore=Ver Vídeo';
$version=2;
$parentid=0;
$ordering=1;
$access=0;
$hits=0;
$metadata='robots=
author=';
$campos='title,alias,introtext,fulltext,state,sectionid,mask,catid,created,created_by,modified,modified_by,checked_out,checked_out_time,publish_up,publish_down,attribs,version,parentid,ordering,access,hits,metadata';
$valores="'$title','$alias','$introtext','$fulltext',$state,$sectionid,$mask,$catid,$created,$created_by,$modified,$modified_by,$checked_out,$checked_out_time,$publish_up,$publish_down,'$attribs',$version,$parentid,$ordering,$access,$hits,'$metadata'";

$conexion=mysql_connect("localhost","zonasafa_db","39564977") 
  or die("No se puede conectar con la base de datos porque: " . mysql_error());
mysql_select_db("zonasafa_jo151",$conexion) or
  die("Problemas en la seleccion de la base de datos porque: " . mysql_error());
mysql_query("INSERT INTO jos_content($campos) VALUES ($valores)", 
   $conexion) or die("Problemas en el select porque: " . mysql_error());
mysql_close($conexion);
echo "El Vídeo fue agregado.";

?>


Es un poco largo el código pero es para que esté todo más claro.
Desde ya muchas gracias por sus respuestas.

PD: Ya he revisado casi todo Google y el manual de mysql_query pero no encontré solución. No pido que hagan mi trabajo, sólo necesito que me ayuden a entender el problema y a solucionarlo.

Por MauXXI

23 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 12 Oct 2008 05:49 am
Problema resuelto:

Debía escribir el nombre de los campos entre acentos francés:

Código :

$campos='`title`,`alias`,`introtext`,`fulltext`,`state`,`sectionid`,`mask`,`catid`,`created`,`created_by`,`modified`,`modified_by`,`checked_out`,`checked_out_time`,`publish_up`,`publish_down`,`attribs`,`version`,`parentid`,`ordering`,`access`,`hits`,`metadata`';

Por MauXXI

23 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 12 Oct 2008 08:40 am

MauXXI escribió:

Problema resuelto:

Debía escribir el nombre de los campos entre acentos francés:

Código :

$campos='`title`,`alias`,`introtext`,`fulltext`,`state`,`sectionid`,`mask`,`catid`,`created`,`created_by`,`modified`,`modified_by`,`checked_out`,`checked_out_time`,`publish_up`,`publish_down`,`attribs`,`version`,`parentid`,`ordering`,`access`,`hits`,`metadata`';

Si, eso te iba a decir, pero no era necesario para todos los campos, solo para los que usas palabras reservadas, como fulltext. En fn, que bueno que lo resolviste.

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox
Citar            
MensajeEscrito el 13 Oct 2008 06:07 pm
¿Sabes por las dudas donde puedo encontrar una lista de palabras reservadas?
Es para no volver a cometer el mismo error.

Por MauXXI

23 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 14 Oct 2008 12:24 am

Por Dano

BOFH

4273 de clabLevel

14 tutoriales
4 articulos
10 ejemplos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Lugar estratégico para vigilarte

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.