Jump to content

[SOLVED] Notice: A non well formed numeric value encountered


paragkalra

Recommended Posts

I have a MySQL database and a table containing many cool quotes. I have written small php code that fetches the data from the database and displays a random quotation on the web-browser.

 

Everything is working but I am getting a strange error along with a random quotation:

Notice: A non well formed numeric value encountered

 

My code is:

<?php

 

 

include "dbconnect.php";

$query1="SELECT `srno` FROM `quotes` ORDER BY `srno` DESC LIMIT 1" ;

$min=1;

$maxdata=mysql_query($query1);

while($maxlimit=mysql_fetch_row($maxdata))

{

$max=`echo "$maxlimit[0]<br=>"`;

 

}

$quoteno=rand($min, $max);

$query2 = "SELECT `quote`,`author` FROM `quotes` where `srno`=$quoteno";

$selectdata = mysql_query($query2);

while($col=mysql_fetch_row($selectdata))

{

 

echo "$col[0]<br>";

echo "- $col[1]<br>";

 

}

?>

 

The exact output that being displayed with a random quote is:

 

Notice: A non well formed numeric value encountered in /var/www/test/rquotes.php on line 13

 

When everything's coming your way, you're in the wrong lane.

- Maxx Power

$max=`echo "$maxlimit[0]<br=>"`;

 

Through above line I am storing the the maximum value contained in "maxlimit" into a variable called "max".

 

That piece of code is working. Problem lies in:

$quoteno=rand($min, $max);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.