View Single Post
  #1 (permalink)  
Old 07-21-06, 05:54 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
Injecting a string into an If Statement ?

ok... this is the code..

PHP Code:

// THE REQUIRED QUESTIONS FOR EACH SURVEY AND ADDED ARGUMENTS FOR EACH QUESTION

    
$rq[1] = array(1,2,3,4,5,6,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,30,31,34,38,40,41,42,43,44,45,46,47,49,50,51,53,55,56,57,58,59,60,61,62,63,64,65,66,67);
    
$rq[2] = array(1,2,4,5,7,9,11,12,14,16,18,19,21,23,25,27,29,30,32,33,35,37);
    
$rq[3] = array(1,2,3,4,5,6,8,9,11,13,15,17,19,20);
    
$aa[3][4] = '&& $q[3] == "1"';
    
$rq[4] = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,26,28,29,30,31,32,33,34,35,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,58,59,60,61);
    
$rq[5] = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,23,24,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41);
    
$rq[6] = array(1,2,3,4,5,6,7,8,10,11,12,13,14,16,17,19);
    
$rq[7] = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28);
    
$rq[8] = array(1,2,3,4,6,7,8,10,11,13,15,17,19,20,21,22);
    
$rq[9] = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33);
    
$rq[10] = array(1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38);
    
    
// FIND ERRORS
    
$count count($rq[$survey_number]);
    for (
$i=0;$i$count;$i++)
        {
        if(isset(
$aa[$survey_number][$i]))
            {
            
$aa_echo $aa[$survey_number][$i];
            }
        else
            {
            
$aa_echo "";
            }
        if(
$q[$rq[$survey_number][$i]] == "NULL")
            {
            echo 
$rq[$survey_number][$i].': Is null and its not ok.<br>';
            }
        else
            {
            echo 
$rq[$survey_number][$i].': Is '.$q[$rq[$survey_number][$i]].' not null.<br>';
            }
        } 
The code is working AS IS but what i want to do (what i cant figure out) is how do i inject a string into an if statment so it reads the string as is and not check the string VAR like so

PHP Code:

if($q[$rq[$survey_number][$i]] == "NULL"// normal


if($q[$rq[$survey_number][$i]] == "NULL" $aa_echo// with a string that should read as...

if($q[$rq[$survey_number][$i]] == "NULL" && $q[3] == "1"
Its a simple question that i cant find an answer to =/

Last edited by nico_swd; 07-21-06 at 01:05 PM. Reason: Merged posts
Reply With Quote