random quote php mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

gwolff2005
Forum Commoner
Posts: 68
Joined: Sun Apr 05, 2009 10:58 am

Re: random quote php mysql

Post by gwolff2005 »

OK. However I still don't get it... so what do I have to change now, to get the error away... Did you have the time to look in myphp? I changed it now back so I have the "old" mistake there... http://www.guntmarwolff.com/indexmain.php.

Ok.. now I deleted the row
while ($row = mysql_fetch_array($result)) {

now mistake comes up but as well no entry :banghead:

What is to do?

THOUSAND THANKS!!!!!!!!!!!!!!
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: random quote php mysql

Post by papa »

Hi,

I don't need to login to your admin panel. I can see that the table does not exist from the image your posted. :)
gwolff2005
Forum Commoner
Posts: 68
Joined: Sun Apr 05, 2009 10:58 am

Re: random quote php mysql

Post by gwolff2005 »

I GOT IT!!!

I wrote the following code

<?php require_once('Connections/Login.php'); ?>
<?php
mysql_select_db($database_Login, $Login);
$query_Recordset1 = "SELECT quotes.quote FROM quotes";
$Recordset1 = mysql_query($query_Recordset1, $Login) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<?php
$user="guntmar";
$password="je20sa05";
$database="guntmar";
$connection=mysql_connect('localhost',$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT `quote`, `author` FROM `quotes` ORDER by rand() LIMIT 1";
$result=mysql_query($query) or die(mysql_error());
$quote = htmlentities(mysql_result($result,$i,"quote"));
$author = htmlentities(mysql_result($result,$i,"author"));
echo("<blockquote>" . $quote . "</cite></blockquote>");
mysql_close($connection);

mysql_free_result($Recordset1);
?>
Post Reply