Lithium Posted April 17, 2012 Posted April 17, 2012 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! Quote
Lithium Posted April 17, 2012 Author Posted April 17, 2012 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! :/ Quote
Lithium Posted April 17, 2012 Author Posted April 17, 2012 comes with the age! ;) Thx Lostone :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.