Forum Moderators: coopster

Message Too Old, No Replies

MySQL and PHP problems

query works in mysql but not in php

         

latifrugs

2:49 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Hi,

Racking my brains here: the following query works ok in mysql, but not when parsing through a php file.


SELECT content FROM placeholder inner join page on placeholder.page_id = page.id where page.link = 'about' AND placeholder.name = $page;

Scene is as follows:

placeholder has a field, 'contents', which I need to display on screen. The row for 'contents' to be displayed is determined by the data in another field in that table called 'name'. If its has the words title or content in it, the data in field 'contents' should be displayed.

The table page is related to placeholder with the field 'id' which matches to 'page_id'.

This query seems to work ok in MySQL outside of php, but not inside of php. I have hardcoded $page without any luck also.

Any ideas? (thanks in advance!)

simon2263

5:08 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



What error message do you get back?

It could be one of these three options:
1. you haven't connected or have failed to connect to the database
2. the quotes in the query are interfering with your PHP string quotes
3. $page doesn't hold what you think it does

latifrugs

6:03 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Thanks.

My query was a bit pants, fixed it and now it works (half) ok. But working on that.

Thanks anyway,