Forum Moderators: open

Message Too Old, No Replies

Proplem in querys WHERE -area

         

Gero_Master

4:56 pm on Oct 31, 2006 (gmt 0)

10+ Year Member



mysql_fetch_array(mysql_query("SELECT * FROM advertising WHERE img_type='".$ad_type."' AND limit_time>'".time()."' AND limit_views<views AND (country_target LIKE '%".$countrycode."%' OR country_target='all') AND country_denied NOT LIKE '%".$countrycode."%' ORDER BY rand() LIMIT 1"));

I'm having problems there. It returns the data when I remove every condition except the first two. I have tested many variations removing different conditions and checking wether it worked. Yet I haven't found a solution. It doesn't give an error message. It just doesn't "find" the result.

Would be helpful if someone could correct my mistages :)

Frank_Rizzo

5:28 pm on Oct 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A quick way to test your syntax is to have an echo line from within the quotes.

echo "SELECT * FROM advertising WHERE img_type='".$ad_type."' AND limit_time>'".time()."' AND limit_views<views AND (country_target LIKE '%".$countrycode."%' OR country_target='all') AND country_denied NOT LIKE '%".$countrycode."%' ORDER BY rand() LIMIT 1";

all I have done there is to cut and paste your mysql statement into an echo.

Run your script and see what appears.