Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Select causing page cannot be displayed error

Status
Not open for further replies.

1DMF

Programmer
Joined
Jan 18, 2005
Messages
8,795
Location
GB
Hello,
I have a select statement
SELECT CatNo,FileID,Artist,Style,Title,Genre,IsNew FROM Singles WHERE 1=1 ORDER BY CatNo DESC

this is failing to return the record I want, yet if i change the 1=1 to anything else i.e. Genre='DNB', the select works fine.

there are only 66 records in the table and only 10 columns of which i'm only selecting 8, so the data being retrieved is fairly small, so why is the select using 1=1 causing such a problem?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Your query would return all records from the table. Does it not do that?
 
No, I get 'Page cannot be displayed'.

It's a PERL script which issues the select command and then uses the template module to display the results, if i pass it a select with the WHERE = anything other than 1=1 , the page displays fine, but when it's 1=1 I get the page cannot be displayed error?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Maybe the problem is the size of the result set. What happens if you drop the "WHERE 1=1" (after all it does nothing)?
 
I found the problem, though I don't understand it.

I was using a form with select list and using onchange to submit form, this would cause the error when ARTIST=All & GENRE=All, however, I changed the onchange to call a subroutine which does this
Code:
document.location.href='[URL unfurl="true"]http://www.mydomian.com/singles.cgi?ARTIST='[/URL] + document.singles.ARTIST.value + '&GENRE=' + document.singles.GENRE.value;
and it works fine!

I have no idea why, it just does, submitting the form errors, passing it get variables via a href redirect works fine - any ideas why this is?


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Code:
SELECT CatNo,FileID,Artist,Style,Title,Genre,IsNew FROM Singles ORDER BY CatNo DESC
Tony suggested the above, did that not work?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
It wasn't the 1=1, it was falling over if the form was submitted. I use 1=1 all the time in my code to get all records.

I'm lost to why this was behaving the way it was, but I've got a work round. I guess I could change me SQL module to not use the WHERE clause if $_[2] is empty rather than passing it in 1=1, it moght make a difference, but I've never had a problem using 1=1 before, so I think it must have been the form being submitted having a problem, though what as I say i'm not sure.

Thanks for the replies.
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top