Fog Creek Software
Discussion Board

PHP / MySQL weirdness

allright, I have a SQL query that, when run directly against my mySQL server through the admin tool, returns two rows.

The very same query returns only one row when run via mysql_query( ) in PHP.

I've checked EVERY possible way this could be a bug in my code, or a 'commit' problem on the database end, and I've even altered the query in the code to remove ALL criteria (so it returns everything) and the row is still missing.  (there are currently only two rows in the table).

What sort of things could be causing this bug??

it's basically like this:


ID      Name          Desc
---      ---------        ----------------------------
1        foo              fubar!


Other_ID      Owner          Contact
------------      -----------      ----------------------------
1                    boo              booFunction
1                    moo              mooFunction

my query:

  INNER JOIN Table_1 A
    ON (B.Other_ID = A.ID)
WHERE A.Name = 'foo'

I should get both rows in Table_2 as a return, right?  And I do if I run the query in phpmyadmin.  But if I run it through PHP I get only the first row.  I've even created a stripped down test script to run just this query, and I get the same result.

what gives?  This is bizarre!

Sunday, July 18, 2004


A better place for these questions might be over at  The forums there are dedicated to just such topics, and you'll find a bigger pool of people to answer you (at times, I'm one of them).

Clay Dowling
Sunday, July 18, 2004

you've got a point.

There's been a few coding questions here, but it's not really the point of the place, is it?


Sunday, July 18, 2004

And can you display your PHP code as well so that one can look at it and find the problem?


Sunday, July 18, 2004

I found the problem.  It was insanely stupid on my part.

misplaced return statement

took me 5 HOURS to find

in my defense, it's a pretty complex system I'm troubleshooting.  :-)

Sunday, July 18, 2004

muppet, you need to simmer down. You make a better case for offshoring than anything else I've ever read.

Raja O'brien
Sunday, July 18, 2004


ok if you say so

I'm the most productive developer in my shop.  I just tend to get a little manic while developing.  Not necessarily a bad thing.

Sunday, July 18, 2004

*  Recent Topics

*  Fog Creek Home