Howdy! problem with code.
Posted: Wed May 20, 2009 1:03 pm
Hi. Can anyone tell me why this code won't work? it's supposed to display a form with two boxes and submit those values into a database when the submit button is clicked.
I'm sure it will be a syntax error. all i get when i run it in a browser is error 500 There is a problem with the page you are trying to reach and it cannot be displayed.
MAny thanks in advance,
Paul.
Code: Select all
<body>
<form action="" method="post">
<Fieldset>
<legend>Add a quote</legend>
<label for "quote">Quote:</label>
<input type="text" name="quote" id="quote" maxlength="255" />
<label for="author">Author:</label>
<input type="text" name="author" id="author" maxlength="40" />
<input type="submit" value="add quote" />
</fieldset>
</form>
<?php
error_reporting(E_ALL);
$user="root";
$pass="****";
$database="afp";
$connection = mysql_connect('localhost',$user,$pass);
@mysql_select_db($database) or die ( "Unable to connect to database :<"
);
if ($_REQUEST['quote'] !="") {
if($_REQUEST['author'] !="" {
$author = $_REQUEST['aurhor'];
} else {
$author= "Anonymous";
}
$quote = $_REQUEST['quote'];
$query="INSERT INTO `quotes` ('quote','author') values('" . mysql_real_escape_string($quote) ."','" . mysql_real_escape_string($author) . "')"
;
$result = mysql_query($query) or die(mysql_error());
echo("inserted quote: " . htmlentities($quote) . " by" . htmlentities($author) . " into database"
);
} else {
echo("<p>Please enter a quote and author</p>");
}
?>
</body>
</html>
MAny thanks in advance,
Paul.