[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

conditional statement for php query to oracle

Posted on 2009-02-18
3
Medium Priority
?
377 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!!!
0
Comment
Question by:diecasthft
  • 2
3 Comments
 
LVL 35

Expert Comment

by:Terry Woods
ID: 23675789
Try:
$query = "SELECT * FROM SCHEME.INSTALLATION WHERE INSTALLATION.NUMBER = '12345'";

Open in new window

0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points
ID: 23675800
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

0
 

Author Closing Comment

by:diecasthft
ID: 31548520
And that does the trick....Thanks so much for your help!!!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question