Re: Off-Topic: Sql en Mysql
| From: | Julio Herrera - Directo | Date: | Sun, 24 Mar 2002 14:57:12 +0000 |
| Subject: | Re: Off-Topic: Sql en Mysql | ||
| References: | 1 2 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-20589@lists.php.net to get a copy of this message | ||
Muchas gracias por responder, el mysql que uso es 3.22.32, la estructura de
la tabla es esta:
CREATE TABLE nucleus_item (
inumber int(11) DEFAULT '0' NOT NULL auto_increment,
ititle varchar(160),
ibody text NOT NULL,
imore text,
iblog int(11) DEFAULT '0' NOT NULL,
iauthor int(11) DEFAULT '0' NOT NULL,
itime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
iclosed tinyint(2) DEFAULT '0' NOT NULL,
idraft tinyint(2) DEFAULT '0' NOT NULL,
ikarma int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (inumber),
UNIQUE inumber (inumber),
KEY itime (itime)
);
Probe el sql por SSH y via web por phpmyadmin, y me manda el mismo error,
probe poniendo el n° de error y me manda lo mismo:
1064: You have an error in your SQL syntax near '(itime), MONTH(itime) ORDER
BY itime DESC' at line 1
Lo extraño qie en mi winblows 98 funciona correctamente, que rraro.
Julio
----- Original Message -----
From: "Angel Fenoy" <afenoy@wol.es>
To: <lista@phpes.com>
Sent: Tuesday, March 19, 2002 10:00 PM
Subject: Re: [PHP-ES] Off-Topic: Sql en Mysql
> Dimarts 19 Març 2002 20:43, Julio Herrera - Directo dixit:
>
> > Hola buenas tardes, baje un administrador de noticias escrito en php
para
> > mysql, lo estoy modificando para uso personal, pero tengo un problema,
la
> > aplicacion funciona 100% en mi pc win98, pero en el servidor hay una
pagina
> > que me manda el siguiente error:
> >
> > You have an error in your SQL syntax near '(itime), MONTH(itime) ORDER
BY
> > itime DESC LIMIT 0, 30' at line 1
>
> Puedes usar la funcion mysql_error() para obtener (algunas veces) una
mejor
> descripción del error. También puedes usar la función mysql_errno(), que
te
> da un número de error, para ver luego qué significa ese número debes usar
la
> utilidad 'perror', un ejecutable que se distribuye junto con mysql y que
por
> tanto deberias tener en tu sistema.
>
> > El sql que se genera es el siguiente:
> > SELECT UNIX_TIMESTAMP(itime) as itime FROM nucleus_item WHERE iblog=1
and
> > UNIX_TIMESTAMP(itime)<=1016562888 GROUP BY YEAR(itime), MONTH(itime)
ORDER
> > BY itime DESC LIMIT 0, 30
>
> - Esta sentencia es sintácticamente correcta, yo la he comprobado en un
mysql
> versión 3.23.41 y funciona, si tienes un mysql más antiguo, es posible que
no
> sea correcta en tu sistema.
>
> - ¿Has probado a hacer este select directamente desde mysql, sin PHP?
>
> - Los campos 'iblog' e 'itime'... ¿Los definiste como enteros al crear la
> tabla?
>
> > Ahora el codigo que permite todo esto es asi:
> >
> > $query = "SELECT UNIX_TIMESTAMP(itime) as itime FROM nucleus_item"
> > . " WHERE iblog=" . $this->getID()
> > . " and UNIX_TIMESTAMP(itime)<=" . $this->getCorrectTime() // don't
show
> > future items! . " GROUP BY YEAR(itime), MONTH(itime) ORDER BY itime
DESC";
> > $res = sql_query($query);
>
> Entiendo que este código genera el select que has señalado antes, el error
no
> estaría pués en el código PHP, sino en el select...
>
> Saludos
> Àngel
>