Ayuda con un error en localhost

Hola buenas noches, he hecho un código en html y php pero al correrlo con localhost me manda el siguiente error:

"Parse error: syntax error, unexpected '[' in C:\AppServ\www\VENTAS.php on line 48"

este es el código:

<html>
<body>
<?php
$host="localhost";
$user="JAVI";
$bd="test";
$con=mysql_connect($host,$user) or die("fallo conexión al servidor");
mysql_select_db($bd,$con) or die("fallo conexion a la BD");
?>
<?php
if(isset($_POST["B1"])){
$btn=$_POST["B1"];
}
if($btn=="Alta"){
$n_venta=$_POST["T1"];
$clav_p=$_POST["T2"];
$precio=$_POST["T3"];
$un=$_POST["T4"];
$fecha=$_POST["T5"];
$marca=$_POST["T6"];
$ID=$_POST["T7"];
$sql=("insert into ventas values('$n_venta','$clav_p','$precio','$un','$fecha','marca','$ID')");
$cs=mysql_query($sql,$con);
if($cs){
echo"<script language='javascript'>alert('La venta se dió de alta correctamente');
</script>";
}
else
{
echo"<script language='javascript'>alert('Alta de venta fallida');
</script>";
}
}
if(isset($_POST["B2"])){
$btn2=$_POST["B2"];
if($btn2=="Consulta"){
}
$n_venta=$_POST["T1"];
$clav_p=$_POST["T2"];
$precio=$_POST["T3"];
$un=$_POST["T4"];
$fecha=$_POST["T5"];
$marca=$_POST["T6"];
$ID=$_POST["T7"];
$sql=("select num_venta, clave, precio, unidades, fecha, marca from ventas where ID_empleado='$ID'");
$cs=mysql_query($sql,$con);
while ($res=mysql_fetch_array($cs)){
$n_venta=[0];
$clav_p=[1];
$precio=[2];
$un=[3];
$fecha=[4];
$marca=[5];
}
}
if(isset($_POST["B3"])){
$btn3=$_POST["B3"];
if($btn3=="Total"){
}
$n_venta=$_POST["T1"];
$precio=$_POST["T3"];
$un=$_POST["T4"];
$sql=("select precio * unidades from ventas where num_venta='$n_venta'");
$cs=mysql_query($sql,$con);
while ($res=mysql_fetch_array($cs)){
$n_venta=[0];
$precio=[1];
$un=[2];
}
}
?>
<form method="POST">
num venta:
<input type="text" name="T1"><br>
clave de producto:
<input type="text" name="T2"><br>
precio:
<input type="text" name="T3"><br>
unidades:
<input type="text" name="T4"><br>
fecha:
<input type="text" name="T5"><br>
marca:
<input type="text" name="T6"><br>
ID empleado:
<input type="text" name="T7"><br>
<input type="text" name="B1" value="Alta"><br>
<input type="text" name="B2" value="Consulta"><br>
<input type="text" name="B3" value="Total">
<input type="label" name="L1" value="<?php echo $cs ?>"><br><br>
</form>
</body>
</html>

ayuda porfavor debo acabar un proyecto gracias salu2

1 respuesta

Respuesta

$n_venta=[0]; <- Posición "0", de que ????? un arreglo, de la consulta que realizas  ???????????

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas