0 Replies Latest reply on Dec 8, 2010 2:30 PM by DrDTP

    mysql select statement where = works and LIKE fails

    DrDTP Level 1

      I am using Flash Builder 4. On the server side I use php and mysql. I created a php dataservice using FB4. My plan had been to allow users to enter a search term and query the database using a "LIKE" statement. FB4 created the php code that I simply modified changing the parameter name. The input parameter is a string.

       

       

      public function getT_caseByID($searchTerm) {

       

      $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename WHERE (title = ?)");

      $this->throwExceptionOnError();

       

      mysqli_stmt_bind_param($stmt, 'i', $searchTerm);

      $this->throwExceptionOnError();

       

      mysqli_stmt_execute($stmt);

      $this->throwExceptionOnError();

       

      mysqli_stmt_bind_result($stmt, $row->idt_case, $row->title, $row->id_author, $row->comments);

       

      if(mysqli_stmt_fetch($stmt)) {

            return $row;

      } else {

            return null;

      }

      }

       

       

      A look at FB4 shows this code returns data.

       

      SupportEquals.jpg

       

      This code works fine but if I make the below change it fails, even when I use the wildcard %. the only change is "=" to "LIKE".

       

      public function getT_caseByID($searchTerm) {

       

      $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename WHERE (title LIKE ?)");

      $this->throwExceptionOnError();

       

      mysqli_stmt_bind_param($stmt, 'i', $searchTerm);

      $this->throwExceptionOnError();

       

      mysqli_stmt_execute($stmt);

      $this->throwExceptionOnError();

       

      mysqli_stmt_bind_result($stmt, $row->idt_case, $row->title, $row->id_author, $row->comments);

       

      if(mysqli_stmt_fetch($stmt)) {

           return $row;

      } else {

           return null;

      }

      }

       

      A look into FB4 shows "void".

      SupportLIKE.jpg

      Any help would be appreciated. I am using localhost on Apache Server on a development computer with Windows XP.