Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/03/2008, 10:28
Avatar de manweb
manweb
 
Fecha de Ingreso: febrero-2008
Mensajes: 16
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: no se añaden registros

Hola Juaniquillo

Te agradezco tu interés. Aqui tienes el código, y no se añade ni un registro.

Un Saludo.
Manweb

<?php require_once('Connections/Apress.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 artist (artist_name) VALUES (%s)",
GetSQLValueString($_POST['artist_name'], "text"));

mysql_select_db($database_Apress, $Apress);
$Result1 = mysql_query($insertSQL, $Apress) or die(mysql_error());
}

mysql_select_db($database_Apress, $Apress);
$query_rstCDS = "SELECT cd_pk FROM cd";
$rstCDS = mysql_query($query_rstCDS, $Apress) or die(mysql_error());
$row_rstCDS = mysql_fetch_assoc($rstCDS);
$totalRows_rstCDS = mysql_num_rows($rstCDS);

mysql_select_db($database_Apress, $Apress);
$query_rstArtists = "SELECT artist_pk FROM artist";
$rstArtists = mysql_query($query_rstArtists, $Apress) or die(mysql_error());
$row_rstArtists = mysql_fetch_assoc($rstArtists);
$totalRows_rstArtists = mysql_num_rows($rstArtists);
?>

<!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=iso-8859-1" />
<title>Mi Colección de CD</title>
</head>

<body>
<h1>Mi colecci&oacute;n de CD</h1>
<p><?php echo $totalRows_rstCDS ?>...CDs de <?php echo $totalRows_rstArtists ?>...artistas</p>
</br>
<h3>Añadir un nuevo artista</h3>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
Artista.
<input name="artist_name" type="text" />
<input name="envio" type="button" value="A&ntilde;adir" />
<input type="hidden" name="MM_insert" value="form1">

</form>
</body>
</html>
<?php
mysql_free_result($rstCDS);

mysql_free_result($rstArtists);
?>