Al intentar conectarme a una tabla de la base de datos me marca el siguiente error:
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 '( fecha_nac ) when '0' then 'dia' when '' then 'a
El código que estoy usando es el siguiente:
Código PHP:
function Conecta()
{
$db_host="localhost";
$db_nombre="x";
$db_user="x";
$db_pass="x";
$link=mysql_connect($db_host, $db_user, $db_pass) or die ("Error conectando a la base de datos.");
mysql_select_db($db_nombre ,$link) or die("Error seleccionando la base de datos.");
return $link;
}
<?
include('conexion.php');
$link = Conecta();
$q = "select
num_cta
, clave_alum
, nombre
, case month(fecha_nac)
when '0' then ''
when month(fecha_nac) in ('10','11','12') then month(fecha_nac)
else concat('0',month(fecha_nac))
end as mes_num_nac
, case year( fecha_nac )
when '0' then 'año'
when '' then 'año'
else year(fecha_nac)
end as anio_nac
, case month( fecha_nac )
when 1 then 'enero'
when 2 then 'febrero'
when 3 then 'marzo'
when 4 then 'abril'
when 5 then 'mayo'
when 6 then 'junio'
when 7 then 'julio'
when 8 then 'agosto'
when 9 then 'septiembre'
when 10 then 'octubre'
when 11 then 'noviembre'
when 12 then 'diciembre'
else 'mes'
end as mes_nac
, case day( fecha_nac )
when '0' then 'día'
when '' then 'día'
else day(fecha_nac)
end as dia_nac
, sem_inicio
, estatus
, case year( fecha_tit )
when '0' then 'año'
when '' then 'año'
else year(fecha_tit)
end as anio_tit
, case month(fecha_tit)
when '0' then ''
when month(fecha_tit) in ('10','11','12') then month(fecha_tit) else concat('0',month(fecha_tit))
end as mes_num_tit
, case month( fecha_tit )
when 1 then 'enero'
when 2 then 'febrero'
when 3 then 'marzo'
when 4 then 'abril'
when 5 then 'mayo'
when 6 then 'junio'
when 7 then 'julio'
when 8 then 'agosto'
when 9 then 'septiembre'
when 10 then 'octubre'
when 11 then 'noviembre'
when 12 then 'diciembre'
else 'mes'
end
as mes_tit
, case day( fecha_tit )
when '0' then 'día'
when '' then 'día'
else day(fecha_tit)
end as dia_tit
, case year( fecha_baja )
when '0' then 'año'
when '' then 'año'
else year(fecha_baja)
end as anio_baja
, case month(fecha_baja)
when '0' then ''
when month(fecha_baja) in ('10','11','12') then month(fecha_baja)
else concat('0',month(fecha_baja))
end as fecha_baja
, case month( fecha_baja )
when 1 then 'enero'
when 2 then 'febrero'
when 3 then 'marzo'
when 4 then 'abril'
when 5 then 'mayo'
when 6 then 'junio'
when 7 then 'julio'
when 8 then 'agosto'
when 9 then 'septiembre'
when 10 then 'octubre'
when 11 then 'noviembre'
when 12 then 'diciembre'
else 'mes'
end
as mes_baja
, case day( fecha_baja )
when '0' then 'día'
when '' then 'día'
else day(fecha_baja)
end as dia_baja
, telefono_1
, telefono_2
, cta_correo
, mensaje
from alumnos
where num_cta = '$num_cta'";
$result = mysql_query($q) or die (mysql_error());
if (mysql_num_rows($result)==0) {
?>
La versión de MySQL que tiene el servidor es la 4.0.16 y la de PHP es 4.3.10
Gracias