Código PHP:
<?php require_once('../Connections/raylink.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 codigos (codigo, tipo_de_producto, descripcion, costo, proveedor) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['codigo'], "text"),
GetSQLValueString($_POST['tipo_de_producto'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['costo'], "text"),
GetSQLValueString($_POST['proveedor'], "text"));
mysql_select_db($database_raylink, $raylink);
$Result1 = mysql_query($insertSQL, $raylink);
mysql_errno($raylink);
// if( mysql_errno() == 1048 ) {
// echo "<br />
//Ningun Campo debe quedar en blanco<br />
//";
// } else {
// echo mysql_error();
// }
//
// if( mysql_errno() == 1062 ) {
// echo "<br />
//Este producto ya exite en la base de datos<br />
//";
// } else {
// echo mysql_error();
// }
}
mysql_select_db($database_raylink, $raylink);
$query_Recordset1 = "SELECT * FROM codigos";
$Recordset1 = mysql_query($query_Recordset1, $raylink) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_raylink, $raylink);
$query_Recordset2 = "SELECT * FROM proveedores";
$Recordset2 = mysql_query($query_Recordset2, $raylink) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
ese es el codigo y muchas gracias por tu interes