Or that.

Or that.
Hi, names James. I am a web developer.
Well, let's all just put down the one guy who's trying to make the Forum a little more interesting.... who cares if you reference the PHP website as a reference? A lot of the time the site can confuse instead of help so I think this thread is a great idea. Anyways...
Today I'm going to talk about the rand() function.
What this function does is generate a random integer between lowestDigit and highestDigit (note that it includes the lowestDigit and highestDigit in it's number range - basically it can return lowestDigit, highestDigit, and everything in between).PHP Code:<?php
// rand ( lowestDigit, highestDigit )
echo rand(1,5); // Outputs any of these: 1 2 3 4 5
?>
I find this function very helpful when you're trying to generate random CAPTCHAs, License Keys/Key Codes, and anything else that requires random anything.
Hope this helps someone out![]()
What ar you on about?
I did this:
So what happens if mysql_num_rows returns an error
Hi, names James. I am a web developer.
I meant if it did, "what happens if" it was to error?
Hi, names James. I am a web developer.
you fail.
It would return the same error message doing it either as:
orPHP Code:if(mysql_num_rows($result)==0) { }
mysql_num_rows only converts the query result from mysql_query, it doesn't contact the database again.PHP Code:$result = mysql_num_rows($query);
if($result==0) { }
Personally I prefer to use:
It is just the same as putting it into a class and executing it:PHP Code:if(mysql_num_rows($result)==0) { }
However the proper way in which to return the amount of rows is by doing it in the SQL itself:PHP Code:if($db->num_rows($query)==0) { }
select count(id) as total from tablename where 1=1
Yea baving im not talkin about that, im talking about his method of doing it.
Hi, names James. I am a web developer.
Want to hide these adverts? Register an account for free!