I'm just starting to get introduced in PHP + MySQL, and I'm following a php tutorial to improve my skills, everything was going well until.. I tried to insert a record in mi DB with INSERT INTO, XAMPP replies me with:
¡Acceso prohibido!
Usted no tiene permiso de accesar al objeto solicitado. Existe la posibilidad de que este protegido contra lectura o que no haya podido ser leido por el servidor.
Por favor contacte con el webmaster en caso de que usted crea que existe un error en el servidor.
Error 403
localhost
26/10/2010 11:23:53
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_jk/1.2.28 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
The code I used seems to be right
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type"content=" text/html;charset=utf-8"/>
<title>No more BloodyShopping</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
// form not submitted
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
NOmbre: <input type="text" name="nombre">
Apellido1: <input type="text" name="apellido1">
Apellido2: <input type="text" name="apellido2">
<input type="submit" name="submit">
</form>
<?php
}
else {
// form submitted
// set server access variables
$host = "localhost";
$user = "root";
$pass = "antonio";
$db = "nmbs";
// get form input
// check to make sure it's all there
// escape input values for greater safety
$nombre = empty($_POST['nombre']) ? die ("ERROR: Pon un nombre") : mysql_escape_string($_POST['nombre']);
$apellido1 = empty($_POST['apellido1']) ? die ("ERROR: Pon un apellido") : mysql_escape_string($_POST['apellido1']);
$apellido2 = empty($_POST['apellido2']) ? die ("ERROR: Pon un apellido") : mysql_escape_string($_POST['apellido2']);
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "INSERT INTO personas (nombre, apellido1, apellido2) VALUES ('$nombre', '$apellido1', $apellido2)";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// print message with ID of inserted record
echo "New record inserted with ID ".mysql_insert_id();
// close connection
mysql_close($connection);
}
?>
</BODY>
</html>
Other functions works well. Please anybody knows where is the trouble, maybe some misconfiguration?
Many thanks for your patience and help,
J.