This issue has mad me mad so I wi=oul b grateful if any one can through somelght abt it. While viewing a report I see the following error and the table does not show any data: Notice: Undefined variable: hasarow in C:\wamp\www\qa\coach\reporta.php on line 330 In my code, I have used the hasarow in the below area: if($showthis){ $hasarow = true;....Line 216 $ID = $row['ID']; Code (markup): And if(!$hasarow){.......Line 299 echo '<tr> <td bgcolor="#FFFF99" colspan="36" style="padding:8px;"><strong> Sorry, No Report available for the selected criteria.</strong></td> </tr>'; Code (markup): I do not know what is wrong. Please help me..
Try defining that variable before you actually use it. Somewhere toward the beginning of the file or before the first use of $hasarow add the code below. $hasarow = false; ... or add this code to the beginning of that file. error_reporting(E_ALL ^ E_NOTICE); or this code, but not both. error_reporting(0); Good luck.
I would however strongly recommend to define that variable with initial value. It's always a good habit to do that way rather than suppressing errors and notices. This is my opinion, which may differ from others
I agree with mastermunj, if you use the variable $hasarow within different functions, you should make it global. The problem is $hasarow is initialized only when $showthis is true. If $showthis is false, the $hasarow variable won't even be created, hence your error when you try to check if it's true or false. If you don't want to initialize the variable first, you can always use this: if( !isset( $hasarow )) { Code (markup):
this is good programming style. even in a production environment where the notices should be disabled, there should be no reason to suppress them! always give an initial value!