Any validation fucntion which returns True/False or 0 or 1 ?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

stephenrodrics
New php-forum User
New php-forum User
Posts: 60
Joined: Thu Mar 14, 2013 6:10 am

Any validation fucntion which returns True/False or 0 or 1 ?

Postby stephenrodrics » Tue Aug 27, 2013 3:37 am

can we use

Code: Select all

mysql_query
to validate whether any record with week = '2013-04-20' already exist or not ?

if not can anyone tell any validation function which returns true or false if we pass query to it

Code: Select all

$returnval = mysql_query("select * from emp where week='2013-04-20')


Code: Select all

if(! $returnval)
{
 echo "no record exist";
}
else
   echo "record exist";

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Any validation fucntion which returns True/False or 0 or

Postby johnj » Tue Aug 27, 2013 5:17 am

first of all please try to use mysqli functions.

second - if you are using mysql then there is a built-in function called mysql_num_rows() (there is also a mysqli_num_rows() ) which will return the number of rows present after running a sql which will tell you whether any record with week = '2013-04-20' already exist or not.

stephenrodrics
New php-forum User
New php-forum User
Posts: 60
Joined: Thu Mar 14, 2013 6:10 am

Re: Any validation fucntion which returns True/False or 0 or

Postby stephenrodrics » Tue Aug 27, 2013 5:30 am

thanks a lot johnj


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests