We help IT Professionals succeed at work.

conditional statement for php query to oracle

Medium Priority
390 Views
Last Modified: 2013-12-12
I'm very new to PHP, I'm really more familiar with Coldfusion, but I find myself needing to do something quick in php. So I have a query in PHP, connecting to an Oracle database...no problem with the connection or the initial query, but when I put a where statement in, things stop working....so I know I'm doing something wrong. The following query works fine:

$query = 'SELECT * FROM SCHEME.INSTALLATION';

But this statement does not:

$query = 'SELECT * FROM SCHEME.INSTALLATION WHERE INSTALLATION.NUMBER = '12345'';

Can anyone shed some light on what I'm doing wrong??? Thansk Alot!!!
Comment
Watch Question

Terry WoodsWeb Developer, specialising in WordPress
CERTIFIED EXPERT
Most Valuable Expert 2011

Commented:
Try:
$query = "SELECT * FROM SCHEME.INSTALLATION WHERE INSTALLATION.NUMBER = '12345'";

Open in new window

Web Developer, specialising in WordPress
CERTIFIED EXPERT
Most Valuable Expert 2011
Commented:
That's because you have single quotes within single quotes - the alternative is to escape them, like this:
$query = 'SELECT * FROM SCHEME.INSTALLATION WHERE INSTALLATION.NUMBER = \'12345\'';

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
And that does the trick....Thanks so much for your help!!!!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.