The PHP code is as follows:
if($duration!='' && $duration_in_hrs!='') {
$duration_in_sec = $duration_in_hrs * 60 * 60;
//echo $grid->mSqlArr['where']; die;
if(empty($grid->mSqlArr['where']) && $grid->mSqlArr['where']=='')
$grid->mSqlArr['where'] = " tests.test_duration = "."'"$duration"'"." ".$duration_in_sec;
else
$grid->mSqlArr['where'] .= " AND tests.test_duration "."'"$duration"'"." ".$duration_in_sec;
}
If I comment the code from line no. 4 to 7 and echo the value of variable $grid->mSqlArr['where']
it's printing the output is_test_cancled='0' AND is_test_archive='0'
But when I remove the comments and run the code the blank screen appears, I can't get how this is happening. I tried to debug, during that I got the following error PHP Parse error: syntax error, unexpected T_VARIABLE in view_tests.php on line 218 Errors parsing view_tests.php
Can you help me in resolving this error. I didn't get after having value how the variable can be unrecognized? Thanks in advance.
The syntax highlighting is a dead giveaway. Check the following line (and the one two below it in your original code snippet):
$grid->mSqlArr['where'] = " tests.test_duration = "."'"$duration"'"." ".$duration_in_sec;
You have a string - " tests.test_duration = "."'"
and then after it you have a variable $duration
and then another string "'"." ".$duration_in_sec
.
If you're meaning to concatenate them all together into one string, you should add the $duration
into the string, eg.
$grid->mSqlArr['where'] = " tests.test_duration = "."'".$duration."'"." ".$duration_in_sec;
(note the extra .
s around the $duration
variable)
You are building your strings wrong
$grid->mSqlArr['where'] = " tests.test_duration = "."'"$duration"'"." ".$duration_in_sec;
should probably be
$grid->mSqlArr['where'] = " tests.test_duration = '$duration' " . $duration_in_sec;
although I don't know what it is that you're trying to build exactly. But you need a .
between each string that you are concatenating together. Also note that you can embed variables in double-quoted strings and they will expand out.