1

I'm running the exact same PHP script on two different servers as a web service for an app. One executes all queries (the one running 5.3.15) and the other (running 5.3.10) does not run certain queries. It creates a server error when I tell some of the queries to execute.

The machine running 5.3.15 is a mac os x lion machine, and the other is and ubuntu 12.04.

Do you guys have any idea what could be going wrong. Here are two examples of queries. The first one works on the php 5.3.10 and the second does not.

Working:

$stmt = $this->db->prepare("SELECT DISTINCT b.id
            FROM a
            LEFT JOIN b
            ON a.item_id = v.id
            INNER JOIN c
            ON a.id = c.item_id
            LEFT JOIN d
            ON c.status_id = d.id
            WHERE d.property = 1");

Server Error-ing:

$stmt = $this->db->prepare("SELECT a.id AS id, d.ordering AS ordering,
            d.name AS name2,
            a.service_id AS service_id, b.name AS name, 
            c.name AS name1, a.due_date AS due_date,
            d.status AS status
            FROM a INNER JOIN b
            ON a.title_id = b.id
            LEFT JOIN c
            ON b.tv_show_id = c.id
            LEFT JOIN d
            ON a.status_id = d.id
            WHERE b.provider_id = ? 
            AND (b.film_id= ? OR b.name 
            LIKE CONCAT('%', ?, '%') OR c.name 
            LIKE CONCAT('%', ?, '%')) LIMIT 2000");

Note: I am very open to all sorts of critiques of these queries, but answers that only say that I'm messy or need to read up on sql will not be very helpful to me. Also, the database names are not actually just letters, I have changed them for security purposes.

The problem is most likely to be in the functions used or something, as the code (before I quickly butchered it by changing around all the names) runs flawlessly in php 5.3.15.

If the error makes no sense, then what else could be going wrong? I ran the queries straight in the mysql console and it worked perfectly, but when I bound_params and executed them based off of passed in variables, the second query fails. Any help is appreciated!!

EDIT:

The error message is: caught SIGTERM, shutting down - I'll look into that. Thank you to all commenters who helped!

Lugubrious
  • 380
  • 1
  • 2
  • 16
  • 1
    What is the error message? – Robert Harvey Aug 08 '13 at 00:05
  • I'm actually having a fair bit of trouble getting it to print one. How would you recommend I get something more informative than server error? I know it is dying on the line $stmt->execute(); – Lugubrious Aug 08 '13 at 00:15
  • 1
    You may be able to find an error log for your database or web server applications. – rutter Aug 08 '13 at 01:17
  • What happens if you run the erring SQL through the database server's command-line interface? What happens if you simplify the erring SQL to `select id from a`, then build it up one clause at a time? – Mike Sherrill 'Cat Recall' Aug 08 '13 at 02:01
  • Mike - I mentioned that I ran the queries straight though the mysql interface and it did work for both. So now I'm just confused about what is going wrong on the php side. Rutter - I'll look into it and edit the main post with my findings. Thanks all! – Lugubrious Aug 08 '13 at 04:17

1 Answers1

0

I realized my problem, and in case someone runs into the same thing, I'm going to share:

My Ubuntu php did not have mysqldb installed, just plain mysql (the default). So, functions like "fetch_assoc()" and "get_result()" do not work. For a work-around, I referred to the following post:

Call to undefined method mysqli_stmt::get_result

Community
  • 1
  • 1
Lugubrious
  • 380
  • 1
  • 2
  • 16