Jump to content

File listing does not work


EPCtech

Recommended Posts

Hi,

In my site people submit games that they have created and let others download them. Anyways, you must upload the game first. And I want it to list the files. What is wrong with this SQL code?

 

SELECT file FROM myfiles WHERE file LIKE '%.zip' OR file LIKE '%.exe' OR file LIKE '%.gmk' OR file LIKE '%.gm6' OR file LIKE '%.gmd' OR file LIKE '%.rar' OR file LIKE '%.zip' AND user='".$name."'

Yes, $name is set.

 

Is there a problem with this code?

 

Thanks for any help,

En-Psyche

Link to comment
https://forums.phpfreaks.com/topic/153948-file-listing-does-not-work/
Share on other sites

so you tried:

SELECT file FROM myfiles WHERE (file LIKE '%.zip' OR file LIKE '%.exe' OR file LIKE '%.gmk' OR file LIKE '%.gm6' OR file LIKE '%.gmd' OR file LIKE '%.rar' OR file LIKE '%.zip') AND user='".$name."'

 

(except replacing user='".$name."' with user='somename')

I don't think that should really matter.  the AND should get evaluated first regardless. But without the parenthesis, it's doing

 

file LIKE '%.zip' AND user='$name' which would evaluate false if it's not a zip file, but then it evaluates all the other ORs and they all come up positive without being filtered by the user.  Hence the parenthesis around all of the ORs, which will first evaluate all of them and then filter against the user. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.