PHP - Error de Php

 
Vista:
sin imagen de perfil
Val: 51
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Error de Php

Publicado por Miguel Freytes (32 intervenciones) el 30/07/2016 23:00:16
Hola estoy creando una pagina para mi empresa pero me da este error: Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/u590208430/public_html/mayorista/facturas.php on line 67 he intentado cambiando varias comillas y no resulta aqui el codigo, la linea 67 vendria siendo la 20
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
<section id="mayoristas">
<div class="contMayoristas">
  <table align="center" border="0" cellpadding="2" cellspacing="2">
<thead><th colspan="1" rowspan="1" align="center">Número de Factura</th> <th colspan="1" rowspan="1" align="center">RIF</th><th width='150' colspan="1" rowspan="1" align="center">Fecha de Emisión</th><th width='150' colspan="1" rowspan="1" align="center">Concepto</th><th width='150' colspan="1" rowspan="1" align="center">Monto</th><th width='150' colspan="1" rowspan="1" align="center">Editar</th><th width='150' colspan="1" rowspan="1" align="center">Borrar</th></thead>
 
<?php
$id_usuario = $_SESSION[id_usuario];
include('../php/cn.php');
    $consulta="SELECT usuarios.rif, facturas.numero, facturas.fecha, facturas.concepto, facturas.monto FROM usuarios, facturas WHERE facturas.id_empresa = $id_usuario";
	$resultado=mysqli_query($conexion, $consulta);
 
    while ($registro = mysqli_fetch_array($resultado)){
echo "
    <tr> 
      <td width='150'>".$registro[numero]."</td>
      <td width='150'>".$registro[rif]."</td>
      <td width='150'>".$registro[fecha]."</td>
      <td width='150'>".$registro[concepto]."</td>
      <td width='150'>".$registro[monto]."</td>
      <td width='150'><a href='editarFactura.php?id=$registro["facturas.id"]'>Editar</a></td>
      <td width='150'><a href='facturas.php?id=$registro["facturas.id"]&idborrar=2'>Borrar</a></td></tr>";
}
?>
 
<?php
$numero = mysqli_num_rows($resultado);
extract($_GET);
if (@$idborrar==2){
 
	$sqlborrar="DELETE FROM facturas where id='"facturas.id"'";
	$resborrar = mysqli_query($conexion, $sqlborrar);
	echo '<script>alert("Registro eliminado correctamente");</script>';
	echo "<script>location.href='facturas.php'</script>";
}
 
?>
</div>
</section>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Javier

Error de Php

Publicado por Javier (7 intervenciones) el 30/07/2016 23:27:43
Hola,
creo que en esa misma linea 20 hay un error en esto: "facturas.id" en vez de contar como unas comillas dobles, cuenta como una simple:
(')'facturas.id'(') .
Si te fijas, facturas.id en la línea 20 aparece en verde y en la línea 21 aparece en rojo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de kip
Val: 2.325
Plata
Ha disminuido 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Error de Php

Publicado por kip (877 intervenciones) el 31/07/2016 01:43:33
Hola, prueba agregando el backslash en el indice de la variable $registro, asi:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
while ($registro = mysqli_fetch_array($resultado)){
echo "
    <tr>
      <td width='150'>".$registro["numero"]."</td>
      <td width='150'>".$registro["rif"]."</td>
      <td width='150'>".$registro["fecha"]."</td>
      <td width='150'>".$registro["concepto"]."</td>
      <td width='150'>".$registro["monto"]."</td>
      <td width='150'><a href='editarFactura.php?id=$registro[\"facturas.id\"]'>Editar</a></td>
      <td width='150'><a href='facturas.php?id=$registro[\"facturas.id\"]&idborrar=2'>Borrar</a></td></tr>";
}

Ademas de eso agregue comillas en cada llamado a los campos que haces a la variable $registros.

Nos avisas si lo solucionas.

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 51
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Error de Php

Publicado por Miguel Freytes (32 intervenciones) el 31/07/2016 02:58:32
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/u590208430/public_html/administracion/facturas.php on line 68 ahora sale este error :(
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de kip
Val: 2.325
Plata
Ha disminuido 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Error de Php

Publicado por kip (877 intervenciones) el 31/07/2016 03:16:11
Mejor concatena las variables, como los haces en las lineas anteriores:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
while ($registro = mysqli_fetch_array($resultado)){
echo "
    <tr>
      <td width='150'>".$registro["numero"]."</td>
      <td width='150'>".$registro["rif"]."</td>
      <td width='150'>".$registro["fecha"]."</td>
      <td width='150'>".$registro["concepto"]."</td>
      <td width='150'>".$registro["monto"]."</td>
      <td width='150'><a href='editarFactura.php?id=".$registro["facturas.id"]."'>Editar</a></td>
      <td width='150'><a href='facturas.php?id=".$registro["facturas.id"]."&idborrar=2'>Borrar</a></td></tr>";
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar