Jump to content

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


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);

I am a newbie and it was perhaps my first php code ...  :)

 

Hehe, we all start somewhere.  I was just asking because I've never seen that before.  I though it may be something that I wasn't aware of...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.