1

I have a single MySQL query created from PHP 5. The Query has 3 SELECT and 2 JOIN clauses. It accesses two databases on a single host using one connection and db1.table1 db2.table2 techniques. I echo the query before running. In PHP the query returns no result and does not error. When I copy and paste the echoed query into SQL in PHPMyAdmin, it returns the correct result.

Why is PHP different to the SQL part of PHPMyAdmin and does anyone have any suggestions about getting it to work in PHP?

1
  • Maybe the connection is not set properly. add or die(mysql_error()) to your mysql_query in the PHP file and tell what error you get. Commented Jul 7, 2011 at 10:19

1 Answer 1

1

Why is PHP different to the SQL part of PHPMyAdmin

It's not.

You're connecting to the wrong database, writing the wrong query, or checking for errors incorrectly.

Sign up to request clarification or add additional context in comments.

4 Comments

I second that, definitely sounds like a Layer8 problem
Thanks folks, it is now working!@Balanivash: or die - it died!
Thanks folks, it is now working! @TomalakGeretkalh: "It's not" got me away from the query (which has taken an hour or two to get working) and on to the connexion. Connecting to the other database made it all work. I am still not sure what the difference is but I will leave the investigation for another day. Thanks for your help.
@Bobby: "The other database"? Well, if for some reason you have two databases, then one of them has no data in and that's why you got no result!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.