[ic] nuttyness with database select

John Allman interchange-users@icdevgroup.org
Fri Sep 6 09:16:10 2002


i am truly reaching the end of my tether here. i was working on my 
flypage when i noticed some products were behaving oddly. i eventually 
traced it down to a problem with a query statement in the page. it 
seemed to be failing to return any data.

i examined both the database and the .txt file in products and the entry 
it is looking for is there. i have gotten the page to print out the sql 
it is using in the query statement and it is fine. i even cut and pasted 
it into my mysql prompt, slapped a semicolon on the end and pressed 
return and it worked fine.

i have looked at the entries in question and can find nothing in common 
with them that could be causing this behaviour.

i have tried a loop statement instead of a query and can confirm that it 
does work. i need to do something rather complicated with the results of 
the query though, and other than specifying arrayref=myref in the query 
statement and playing about with $Tmp-> {myref} in perl afterwards i 
dont know how to do this. when i nested a perl block inside the loop 
statement that worked it seemed to execute the block only once.

can anyone give me any help or suggestions? i've tried to write a 
usertag to go inside the loop statement but it complains about my trying 
to access a database. if anyone wants i'll put my tag up.

i have stipped the flypage down to these lines and nothing happens:

[query arrayref=myref sql="select code,descrip,template from cattable 
where code=252"]
<!--body not used... -->
[/query]
[perl]
        foreach $line (@$ary) {
                ($code,$descrip,$template) = @$line;
                $Scratch->{foundstuff}="yes";
        }
[/perl]
did i find stuff?[scratch foundstuff] says i<br>

it just prints out "did i find stuff? says i"

in mysql:

mysql> select code,descrip,template from cattable where code=252;
+------+----------------+-------------+
| code | descrip        | template    |
+------+----------------+-------------+
|  252 | Animal Kingdom | subcatcompl |
+------+----------------+-------------+
1 row in set (0.08 sec)

there is a corresponding entry in cattable.txt with code 252.

please if anyone can explain what is going on or at least suggest a way 
to avoid the problem i would greatly appreciate it!

thanks

John