Re: PHP query to mysql database returns emtpy data, but Query Browser shows records

From: Date: Thu, 06 Jan 2005 06:50:11 +0000
Subject: Re: PHP query to mysql database returns emtpy data, but Query Browser shows records
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-37995@lists.php.net to get a copy of this message
Hi, You have: $query example = SELECT description from cpProducts where category='39 47 48 172' don't you want to add a logical operator such as OR, possibly AND $query example = SELECT description from cpProducts where category='39 OR 47 OR 48 OR 172' graeme. Jason Walker wrote:
Here is the query:
     function ReturnPackageDescriptions($pack, $cat, $hotcat, $hotid){
             $comIB = $cat . " " . $pack . " " . $hotcat . " " . $hotid;
          $catLength = strlen($comIB);
          echo $catLength;
          $query = "SELECT description from cpProducts where category='" . $cat . " " . $pack . " " . $hotcat . " " . $hotid . "'";
          echo "<bR>" . $query . "<br>";
             echo "combined package number = " . $comIB . "<br>";
               $retval = "";
          $link = mysql_connect($config['host'],$config['user'],$config['pass']) or die("Could not connect");
              mysql_select_db('stc_store') or die("Unable to connect to the default database");
                  $result = mysql_query($query) or die("Unable to pull the menu objects for main event details");
          echo mysql_affected_rows() . "<br>";
                while ($results = mysql_fetch_array($result, MYSQL_ASSOC)){
                     extract($results);
                   echo $description;
               $retval = $description;
          }
                       mysql_free_result($result);
             mysql_close($link);
          return $retval;
} I have some extra 'echo' statements to see the progress on the web page. If I remove the 'where' clause within the SQL statement, I get rows. But when I add the 'where' portion, no records are returned. Here is an example of what the query looks like: $query example = SELECT description from cpProducts where category='39 47 48 172' When I run the same query in MYSQL Control center or Query Browser, no problem. I use this function template for my SELECT statements. Please let me know if there is something missing from the code. Thanks. Jason Walker jwalker@desktophero.com <mailto:jwalker@desktophero.com> http://www.desktophero.com ------------------------------------------------------------------------ No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.298 / Virus Database: 265.6.8 - Release Date: 1/3/2005


« previous php.db (#37995) next »