Jump to content
MakeWebGames

Lights needed here


Lithium

Recommended Posts

Need some lights here...

 

$x = array(array('a',array('a1','a2','a3','a4','a5')),array('b',array('b1','b2','b3')),array('c',array('c1','c2','c3','c4')));

output:

Array (
   [0] => Array ( [0] => a
                  [1] => Array ( [0] => a1 
                                 [1] => a2 
                                 [2] => a3 
                                 [3] => a4 
                                 [4] => a5 )
                               )
   [1] => Array ( [0] => b
                  [1] => Array ( [0] => b1
                                 [1] => b2
                                 [2] => b3 )
                               )
   [2] => Array ( [0] => c
                  [1] => Array ( [0] => c1
                                 [1] => c2
                                 [2] => c3
                                 [3] => c4 )
                               )
   )

Now applying into a query

    foreach ($x as $key1 => $value1) {    
       foreach ($x[$key1][1] as $key2 => $value2) {
           $user = 1; /* set here for testing purposes only */
           $sql = "SELECT `tID` FROM `test` WHERE `tTYPE` = '".$x[$key1][0]."' AND `tWHEN` = '".$value2."' AND `aUSER` = '".$user."'";
           $xx = mysql_query($sql);
           if (!mysql_num_rows($xx)) {
               echo $sql."\cr";
               echo "Empty ".$x[$key1][0]." -> ".$value2."\cr";
           }   
       }
    }

this results in a few queries like this if no match on db...

SELECT `tID` FROM `test` WHERE `tTYPE` = 'b' AND `tWHEN` = 'b2' AND `aUSER` = '1'

and the echo

Empty b -> b2

 

despite all this... i keep getting "mysql_num_rows() expects parameter 1 to be resource, boolean given"

Any light why this occurs or how to overcome this would be appreciated!

Link to comment
Share on other sites

I feel bad now... damn stupid mistake!!!!!!!!!!!!!!!!

 

Error processing: SELECT `tID` FROM `test` WHERE `tTYPE` = 'a' AND `tWHEN` = 'a1' AND `aUSER` = '1'

 

`aUSER`ought to be `tUSER`and i didn't even noticed it, only when i saw your output and compared, i noticed the damn typo! :/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...