Database info not displaying correctly

This is a discussion on "Database info not displaying correctly" within the PHP Forum section. This forum, and the thread "Database info not displaying correctly are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 23rd, 2008, 17:38
Junior Member
Join Date: Sep 2006
Location: Here
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Database info not displaying correctly

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.
Reply With Quote

  #2 (permalink)  
Old May 24th, 2008, 20:39
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Database info not displaying correctly

There appears to be no problem with your code but i am a bit confused as what you are trying achieve. Here is what i have gathered so far:

You have a working database & you are trying to send post data from the form from these to fields here 'quote' & 'author' into the database using the 'add_quote.php' to handle the transfer from form to database right???

So how and were are you displaying the the data from the database or do you mean it wont display or show up in the database once posted??

If its the database check you or someone else have not set a option in the database to only display the entrys by date or time ie: and

PHP: Select all

 
and DATE_ADDcreated_atINTERVAL 30 DAY ) > NOW() 


if you need help displaying the database rows on a web page the use the following code below:

PHP: Select all

<?php
 
$connection 
mysql_connect('localhost','username','password');
 
mysql_select_db('DATABASE');
 
$sql "SELECT * FROM quotes order by quotesid";
 
$result mysql_query($sql);
 
$row mysql_fetch_array($result);
 
// Then simpley echo out the rows using the the echo statement below:
 
<?php  echo $row['qoutes'[; ?>  <br />
 
<?php echo $row['author']; ?> 
?>
Hope this helps you out mate

Last edited by longstand; May 24th, 2008 at 20:44.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Use info from Database in a script ??? WebNinja PHP Forum 2 May 3rd, 2008 00:59
Images not displaying correctly leighhobson89 Web Page Design 2 Nov 29th, 2007 16:33
Displaying diff info on the same page waheeddin Web Page Design 1 Feb 23rd, 2007 19:56
Displaying correctly in every browser except IE promod Web Page Design 15 Feb 16th, 2007 16:28
displaying data from my database franknu PHP Forum 20 Jun 16th, 2006 09:43


All times are GMT. The time now is 16:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43