Error de sintaxis
Publicado por Pablo (2 intervenciones) el 20/12/2019 18:15:36
Buen dia a todos, les traigo una consulta basada en un problema que tengo al momento de hacer una consulta.
Tengo 3 Tablas:
VIAJEROS
cod_via- int-(clave principal)
ced_via -varchar
nom_via-varchar
ape_via-varchar
dir_via-varchar
tel_via-varchar
fec_via -date
ori_via-int (foranea)
des_via- int (foranea)
obs_via.
ORIGEN
cod_ori- int (Clave principal)
ciud_ori varchar
DESTINOS
cod_des int (Clave principal)
ciud_des varchar
Lo que necesito es buscar a través de DESTINOS = Ciudad de destino.
Pagina de consulta: consultar_viaj_ced.php
--------------------------------------------------------------------
PAGINA DE PROGRAMA: consultar_viajeros.php
-------------------------------------------------------------------------------------------
Al hacer la busqueda ejemplo "SALTA" dato incorporado en la base de datos. me saje este error:
"Problemas en el select:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE Des.cod_des= Vi.des_via and Des.ciud_des='.SALTA'' at line 7"
Que puedo estar haciendo mal? Cualquier ayuda se agradece mucho.
Saludos.
Tengo 3 Tablas:
VIAJEROS
cod_via- int-(clave principal)
ced_via -varchar
nom_via-varchar
ape_via-varchar
dir_via-varchar
tel_via-varchar
fec_via -date
ori_via-int (foranea)
des_via- int (foranea)
obs_via.
ORIGEN
cod_ori- int (Clave principal)
ciud_ori varchar
DESTINOS
cod_des int (Clave principal)
ciud_des varchar
Lo que necesito es buscar a través de DESTINOS = Ciudad de destino.
Pagina de consulta: consultar_viaj_ced.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include_once 'encabezado1.php';
echo '<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />';
include'conexion.php';
?>
<body bgcolor="white">
<script type="text/javascript" src="js/funciones.js"></script>
<center>
<h1 class="register_title">CONSULTAR VIAJEROS POR DESTINO</h1>
<br> <br>
<form name="cons_viajero" class="register" action="consultar_viajeros.php" method="post">
Inserte el destino a consultar
<br> <br>
<input type="text" name="desti_via">
<br><br>
<input type="submit" value="buscar">
</form>
<link rel="stylesheet" href="css/ingreso_datos.css" type="text/css" rel="stylesheet" media="all" />
</body>
<br>
</center>
<?php
include_once 'pie.php';
?>
--------------------------------------------------------------------
PAGINA DE PROGRAMA: consultar_viajeros.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include_once 'encabezado1.php';
include_once 'conexion.php';
mysqli_select_db($conexion,"bdd_agencia_viajes");
$registros=mysqli_query($conexion, "SELECT Vi.cod_via, Vi.ced_via, Vi.nom_via, Vi.ape_via,
Vi.tel_via, Vi.fec_via, Vi.ori_via, Ori.ciud_ori, Vi.des_via, Des.cod_des, Des.ciud_des
FROM destinos viajeros
INNER JOIN origen Ori ON Vi.ori_via=Ori.cod_ori
INNER JOIN viajeros Vi ON Des.cod_des=Vi.des_via
order by Des.cod_des asc
WHERE Des.cod_des= Vi.des_via and Des.ciud_des='.$_REQUEST[desti_via]'")
or die ("Problemas en el select:".mysqli_error($conexion));
echo '<center>';
echo '<br>'.'<table border=1 bgcolor="white"';
echo '<tr>';
echo '<th colspan=12>'.'<b/>'.'CONSULTA DE VIAJEROS'.'</th>';
echo '</tr>';
echo '<tr>';
echo '<th>'.'<b/>'.'CÓDIGO'.'</th>';
echo '<th>'.'<b/>'.'CEDULA'.'</th>';
echo '<th>'.'<b/>'.'NOMBRE'.'</th>';
echo '<th>'.'<b/>'.'APELLIDO'.'</th>';
echo '<th>'.'<b/>'.'TELEFONO'.'</th>';
echo '<th>'.'<b/>'.'FECHA'.'</th>';
echo '<th>'.'<b/>'.'ORIGEN'.'</th>';
echo '<tr>';
if ($reg=mysqli_fetch_array($registros))
{
echo '<tr>';
echo '<td>'.$reg['cod_via'].'</td>';
echo '<td>'.$reg['ced_via'].'</td>';
echo '<td>'.$reg['nom_via'].'</td>';
echo '<td>'.$reg['ape_via'].'</td>';
echo '<td>'.$reg['tel_via'].'</td>';
echo '<td>'.$reg['fec_via'].'</td>';
echo '<td>'.$reg['ciud_ori'].'</td>';
echo '</tr>';
}
else{
echo "No existe ese destino.";
}
echo '</table>';
echo '<br>';
echo '</center>';
echo '
<link href="css/mostrar_datos.css" type="text/css" rel="stylesheet" media="all" />
';
mysqli_close($conexion);
include_once 'pie.php';
?>
-------------------------------------------------------------------------------------------
Al hacer la busqueda ejemplo "SALTA" dato incorporado en la base de datos. me saje este error:
"Problemas en el select:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE Des.cod_des= Vi.des_via and Des.ciud_des='.SALTA'' at line 7"
Que puedo estar haciendo mal? Cualquier ayuda se agradece mucho.
Saludos.
Valora esta pregunta


0