necesito su ayudano se me conecta con la BD
Publicado por jose (3 intervenciones) el 19/07/2009 20:32:35
[B]buenos dias espero q me puedan ayudar ya que estoy algo enredado..
mi pag no se quiere conectar con mi base de dato, no se donde pueda estar el error
hice mi pag normal en html y de ahi llamo a mi pag de Php para q se conecte con mi base de dato pero nada
aqui esta la pagina normal en html: [/B]
<!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>REGISTRO DE MATERIAL</title>
</head>
<body>
<p align="center"><strong>REGISTRO DE MATERIAL</strong></p>
<form id="form1" name="form1" method="post" action="procesoregmaterial.php">
<p align="center"> </p>
<table width="420" border="0">
<tr>
<th width="211" scope="col"><label>
<div align="left">Nombre del Material</div>
</label></th>
<th width="193" scope="col"><div align="left">
<input type="text" name="nombre_mat" id="nombre_mat" />
</div></th>
</tr>
<tr>
<th scope="col"><div align="left">Descripcion del Material</div></th>
<th scope="col"><label>
<div align="left">
<input type="text" name="desc_mat" id="desc_mat" />
</div>
</label></th>
</tr>
<tr>
<th scope="col"><div align="left">Precio Unitario</div></th>
<th scope="col"><label>
<div align="left">
<input type="text" name="prec_unit" id="prec_unit" />
</div>
</label></th>
</tr>
</table>
<p> </p>
<p>
<label>
<input type="submit" name="enviar" id="enviar" value="Enviar" />
</label>
<label>
<input type="submit" name="cancelar" id="cancelar" value="Cancelar" />
</label>
</p>
</form>
</body>
</html>
[B]y aqui esta la pag de PHP donde hago para que se conecte con la BD[/B]
<?php
include_once("Connections/almacen.php");
$db_conexion= mysql_connect("$hostname_almacen", "$username_almacen", "$password_almacen") or die("No se pudo conectar a la Base de datos") or die(mysql_error());
mysql_select_db("$database_almacen") or die(mysql_error());
$nombre_mat= $_POST['nombre_mat'];
$desc_mat=$_POST['desc_mat'];
$prec_unit=$_POST['prec_unit'];
if (!isset($_POST['enviar'])) {
header ('location: regmaterial.php');
}
if (($nombre_mat == "") or ($desc_mat == "") or ($prec_unit == "")) {
echo "Faltan Datos <a href='javascript:history.back()'>Volver</a>";
} else {
$sql= "INSERT INTO material (cod_mat, nombre_mat, desc_mat, precio_unit)
VALUES ('','$nombre_mat', '$desc_mat', '$prec_unit')";
$result=mysql_query($sql);
header ("location: regmaterial.php?msg=1");
}
?>
donde me sugieren que pueda estar el error.....
mi pag no se quiere conectar con mi base de dato, no se donde pueda estar el error
hice mi pag normal en html y de ahi llamo a mi pag de Php para q se conecte con mi base de dato pero nada
aqui esta la pagina normal en html: [/B]
<!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>REGISTRO DE MATERIAL</title>
</head>
<body>
<p align="center"><strong>REGISTRO DE MATERIAL</strong></p>
<form id="form1" name="form1" method="post" action="procesoregmaterial.php">
<p align="center"> </p>
<table width="420" border="0">
<tr>
<th width="211" scope="col"><label>
<div align="left">Nombre del Material</div>
</label></th>
<th width="193" scope="col"><div align="left">
<input type="text" name="nombre_mat" id="nombre_mat" />
</div></th>
</tr>
<tr>
<th scope="col"><div align="left">Descripcion del Material</div></th>
<th scope="col"><label>
<div align="left">
<input type="text" name="desc_mat" id="desc_mat" />
</div>
</label></th>
</tr>
<tr>
<th scope="col"><div align="left">Precio Unitario</div></th>
<th scope="col"><label>
<div align="left">
<input type="text" name="prec_unit" id="prec_unit" />
</div>
</label></th>
</tr>
</table>
<p> </p>
<p>
<label>
<input type="submit" name="enviar" id="enviar" value="Enviar" />
</label>
<label>
<input type="submit" name="cancelar" id="cancelar" value="Cancelar" />
</label>
</p>
</form>
</body>
</html>
[B]y aqui esta la pag de PHP donde hago para que se conecte con la BD[/B]
<?php
include_once("Connections/almacen.php");
$db_conexion= mysql_connect("$hostname_almacen", "$username_almacen", "$password_almacen") or die("No se pudo conectar a la Base de datos") or die(mysql_error());
mysql_select_db("$database_almacen") or die(mysql_error());
$nombre_mat= $_POST['nombre_mat'];
$desc_mat=$_POST['desc_mat'];
$prec_unit=$_POST['prec_unit'];
if (!isset($_POST['enviar'])) {
header ('location: regmaterial.php');
}
if (($nombre_mat == "") or ($desc_mat == "") or ($prec_unit == "")) {
echo "Faltan Datos <a href='javascript:history.back()'>Volver</a>";
} else {
$sql= "INSERT INTO material (cod_mat, nombre_mat, desc_mat, precio_unit)
VALUES ('','$nombre_mat', '$desc_mat', '$prec_unit')";
$result=mysql_query($sql);
header ("location: regmaterial.php?msg=1");
}
?>
donde me sugieren que pueda estar el error.....
Valora esta pregunta


0