PHP and MySQL problem

Hi all,

I'm working on pulling data from a mySQL database through a php page for an internship that I have. However, I seem to have a problem in that some data will not be returned in my resultset for an unknown reason. The php for the sql query I am trying to execute is as follows:

PHP:
$sql_kcnc = mysql_query("SELECT count(*) as count, 
                              CASE url
                                    WHEN 'http://kindervision.org/kcnc_the_greatest_save/' THEN '<b class=\"red\">KCNC TGS Page</b>'
                                    WHEN 'http://kindervision.org/kindiclub/retrieve.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Kindclub Quiz Page</b>'
                                    WHEN 'http://kindervision.org/kindiclub/score.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Kindclub Score Page</b>'
                                    WHEN 'http://kindervision.org/wt/wt_retrieve.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Wolftraps Quiz Page</b>'
                                    WHEN 'http://kindervision.org/wt/wt_score.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Wolftraps Score Page</b>'
                                    WHEN 'http://kindervision.org/parents/retrieve.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Parents Quiz Page</b>'
                                    WHEN 'http://kindervision.org/parents/score.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Parents Score Page</b>'
                                    WHEN 'http://kindervision.org/safety_info.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Safety Tip of the Day Page</b>'
                                    WHEN 'http://kindervision.org/wolftraps/index.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Wolftraps Page</b>'
                                    WHEN 'http://kindervision.org/products.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Products Page</b>'
                                    WHEN 'http://kindervision.org/events.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Events Page</b>'
                                    WHEN 'http://kindervision.org/event/index.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Events Video Page</b>'
                                    WHEN 'http://kindervision.org/predatorsafety/asktheexperts.php?state=CO&city=Denver' THEN '<b class=\"red\">KCNC Predator Safety Page</b>'
                                    WHEN 'http://kindervision.org/kvvideo/retrieve.php?state=CO&city=Denver&chapter=1' THEN '<b class=\"red\">KCNC KVVideo Page</b>'
                              ELSE url
                               END AS url
                             FROM statTracker
                            WHERE 
                                url IN('http://kindervision.org/kcnc_the_greatest_save/',
                                       'http://kindervision.org/kindiclub/retrieve.php?state=CO&city=Denver',
                                       'http://kindervision.org/kindiclub/score.php?state=CO&city=Denver',
                                       'http://kindervision.org/wt/wt_retrieve.php?state=CO&city=Denver',
                                       'http://kindervision.org/wt/wt_score.php?state=CO&city=Denver',
                                       'http://kindervision.org/parents/retrieve.php?state=CO&city=Denver',
                                       'http://kindervision.org/parents/score.php?state=CO&city=Denver',
                                       'http://kindervision.org/safety_info.php?state=CO&city=Denver',
                                       'http://kindervision.org/wolftraps/index.php?state=CO&city=Denver',
                                       'http://kindervision.org/products.php?state=CO&city=Denver',
                                       'http://kindervision.org/events.php?state=CO&city=Denver',
                                       'http://kindervision.org/event/index.php?state=CO&city=Denver',
                                       'http://kindervision.org/predatorsafety/asktheexperts.php?state=CO&city=Denver',
                                       'http://kindervision.org/kvvideo/retrieve.php?state=CO&city=Denver&chapter=1'
                                        )
                            AND thedate_visited = '$begin_date'
                             GROUP BY url
                            ORDER BY count DESC") 
                            or die(mysql_error());
However, when I attempt to execute it inside the php page i am constructing, the following line in the IN statement of the WHERE clause does not seem to return results even though when I run the exact same query inside the database it does return results for the statement below.

PHP:
'http://kindervision.org/kcnc_the_greatest_save/',
I am completely stumped on this one as I am pretty sure that the SQL syntax is grammatically correct. Everything else in the IN statement of the WHERE clause seems to return otherwise.

Thanks in advance to anyone who can help me solve this...
 
Are you given an error when the page is executed?

I find that script intensly hard to follow, as you are doing all of the data gathering via MySql query rather than utilisizing PHP functions. Sometimes getting data from a database is as simple as:
Code:
$data = mysql_query("SELECT * FROM database WHERE column=columndata");
while ($info = mysql_fetch_assoc($data))
  echo $info."<br>\n";
 
Back