Código HTML :
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado"> </td> <td class="celda"></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado">Recorrido:</td> <td class="celda"><input type="text" tabindex="0" name="recorrido" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado">Tiempo:</td> <td class="celda"><input type="text" name="tiempo" id= "hora" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado">Distancia:</td> <td class="celda"><input type="text" name="distancia" id="espacio" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado">Calorias:</td> <td class="celda"><input type="text" name="calorias" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado">Kmh:</td> <td class="celda"><input type="text" name="kmh" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="right" nowrap="nowrap" class="encabezado"> </td> <td class="celda"><input type="submit" value="Insertar registro" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form>
El código php donde intento insertar los valores en la Bd es:
Código PHP :
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
if (isset($_POST["hora"])){
$tempo_var=$_POST["hora"];
$desglose=explode(":",$tempo_var);
$segundos=($desglose[0]*3600)+($desglose[1]*60)+$desglose[2];}
if (isset($_POST["espacio"])){
$space_var=$_POST["espacio"]*1000;
$speed=($space_var/$segundos)*3.6;}
$insertSQL = sprintf("INSERT INTO datos (recorrido, tiempo, distancia, calorias, kmh) VALUES (%s, %s, %s, %s,$speed)",
GetSQLValueString($_POST['recorrido'], "text"),
GetSQLValueString($_POST['tiempo'], "date"),
GetSQLValueString($_POST['distancia'], "double"),
GetSQLValueString($_POST['calorias'], "double"),
GetSQLValueString($_POST['kmh'], "double"));
mysql_select_db($database_conexion_bici, $conexion_bici);
$Result1 = mysql_query($insertSQL, $conexion_bici) or die(mysql_error());
$insertGoTo = "insercion_correcta.php";Me da el error:
Notice: Undefined variable: speed in C:\xampp\htdocs\bicicleta\index.php on line 52
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 ')' at line 1
¿Qué tengo mal?, ¿Como lo puedo arreglar?. Gracias.
