I am having a problem with a
PHP&MySQL quote of the day script I'm using. The script works. I downloaded one called "The World's simplest
PHP Message/Quote of the Day Script". It can be found here:
http://www.interaction-design.org/ma...te_of_the_day/
The problem is this: I can enter more quotes via phpMyAdmin and they display, but when I submit new quotes via
PHP form to the database, it won't display in the final page. The quote & author information is in the database, but it does not show in the end page. As the script cycles through the database, some days it will display the quote and author correctly, then the next few are blank.
Is there a problem with the code?
To enter first quote & author
- HTML: Select all
<html>
<body>
<form method="post" action="add_quote.php">
Quote: <input type="text" name="quote" /><br />
Author: <input type="text" name="author" /><br />
<input type="submit" value="Add 1st Quote">
</form>
</body>
</html>
To send quote & author to database...
...then to add another quote & author
- PHP: Select all
<?php
$con = mysql_connect("localhost","USERNAME","PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql="INSERT INTO quotes (Quote, Author)
VALUES
('$_POST[quote]','$_POST[author]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "The quote was added.";
mysql_close($con)
?>
<html>
<body>
<form method="post" action="add_quote.php">
Quote: <input type="text" name="quote" /><br />
Author: <input type="text" name="author" /><br />
<input type="submit" value="Add Next Quote" />
</form>
</body>
</html>
Or maybe its just a setting in phpMyAdmin I can adjust. Anyone have any ideas?
Thanks.