Respuesta: Problema con un Script y este es el formulario del php
permutas.php
<?php require_once('../Connections/loto_vicma.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO permuta (id_cod, loteria, str, perms, opcion, hora, monto) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_cod'], "int"),
GetSQLValueString($_POST['loteria'], "text"),
GetSQLValueString($_POST['str'], "int"),
GetSQLValueString($_POST['perms'], "int"),
GetSQLValueString($_POST['opcion'], "text"),
GetSQLValueString($_POST['hora'], "int"),
GetSQLValueString($_POST['monto'], "int"));
mysql_select_db($database_loto_vicma, $loto_vicma);
$Result1 = mysql_query($insertSQL, $loto_vicma) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO permuta (id_cod, loteria, str, perms, opcion, hora, monto) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_cod'], "int"),
GetSQLValueString($_POST['loteria'], "text"),
GetSQLValueString($_POST['str'], "int"),
GetSQLValueString($_POST['perms'], "int"),
GetSQLValueString($_POST['opcion'], "text"),
GetSQLValueString($_POST['hora'], "text"),
GetSQLValueString($_POST['monto'] * 6, "int"));
mysql_select_db($database_loto_vicma, $loto_vicma);
$Result1 = mysql_query($insertSQL, $loto_vicma) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO permuta (id_cod, loteria, str, perms, opcion, hora, monto) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_cod'], "int"),
GetSQLValueString($_POST['loteria'], "text"),
GetSQLValueString($_POST['str'], "int"),
GetSQLValueString($_POST['perms'], "int"),
GetSQLValueString($_POST['opcion'], "text"),
GetSQLValueString($_POST['hora'], "text"),
GetSQLValueString($_POST['monto'], "int"));
mysql_select_db($database_loto_vicma, $loto_vicma);
$Result1 = mysql_query($insertSQL, $loto_vicma) or die(mysql_error());
}
mysql_select_db($database_loto_vicma, $loto_vicma);
$query_Recordset1 = "SELECT MAX(id) AS id FROM cod_loteria";
$Recordset1 = mysql_query($query_Recordset1, $loto_vicma) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>
<script type="text/javascript" src="js/permute.js"></script>
<script type="text/javascript" src="js/validarNum.js"></script>
<body style="background:url(Css/fondo.jpg) no-repeat; width:auto; height:auto">
<form method="POST" action="<?php echo $editFormAction; ?>" name="form1" onsubmit="calcPerms(this.str.value, true, this.perms, this.delimiter.value); return false;">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;">Loteria:</td>
<td><select name="loteria" value="" >
<option value="">-</option>
<option value="leo A">Leon A</option>
<option value="leo B">Leon B</option>
<option value="zam">Zamarano</option>
<option value="cor A">Coro A</option>
<option value="cor B">Coro B</option>
<option value="nuet A">Nuestro Triple A</option>
<option value="nuet B">Nuestro Triple B</option>
<option value="tript A">Triple Tachira A</option>
<option value="tript B">Triple Tachira B</option>
<option value="zul A">Zulia A</option>
<option value="zul B">Zulia B</option>
<option value="chan A">Chance A</option>
<option value="chan B">Chance B</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;">Numero:</td>
<td><input type="text" name="str" value="" size="15" maxlength="9" title="Type your string to permute here and then press Enter or Return." /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;">Jugada:</td>
<td><textarea type="text" name="perms" rows="4" cols="20" wrap="soft" readonly="readonly" size="32"/></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;">Hora:</td>
<td><select name="hora" value="" >
<option value="">-</option>
<option value="12:00 m">12:00 PM</option>
<option value="12:30 pm">12:30 PM</option>
<option value="12:45 pm">12:45 PM</option>
<option value="1:00 pm">1:00 PM</option>
<option value="4:00 pm">4:00 PM</option>
<option value="4:30 pm">4:30 PM</option>
<option value="4:45 pm">4:45 PM</option>
<option value="5:00 pm">5:00 PM</option>
<option value="7:00 pm">7:00 PM</option>
<option value="7:30 pm">7:30 PM</option>
<option value="7:45 pm">7:45 PM</option>
<option value="8:00 pm">8:00 PM</option>
<option value="9:00 pm">9:00 PM</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;">Monto:</td>
<td><input type="text" name="monto" value="" size="15" onkeypress="return soloLetras(event)" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" style="color:#FFFFFF; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif; font-size:16px;"> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Calculate Permutations" /></td>
</tr>
</table>
<input type="hidden" name="id_cod" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="hidden" name="opcion" value="Permuta" />
<input type="hidden" name="delimiter" value=", " size="4" title="Use \n for newline (one permutation per line)" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?> |