Trouble binding parms with LIKE w/Oracle

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
StOops
Forum Newbie
Posts: 2
Joined: Tue Jun 11, 2002 1:56 pm

Trouble binding parms with LIKE w/Oracle

Post by StOops »

Hey guys and gals,

Having a bit of a rough time binding a parm with a LIKE statement

If I write

Code: Select all

SELECT user_id, addr1
FROM USER
WHERE UPPER(USERNAME) LIKE '%$user%'
all is well and fine.


However,

Code: Select all

SELECT user_id, addr1
FROM USER
WHERE UPPER(USERNAME) LIKE '%:uname%'

OCIBindByName($sth, ":uname", $myUser, -1);
gets me
OCIBindByName: ORA-01036: illegal variable name/number in script name.

Thinking maybe it was the % symbol it was choiking on I moved the % to the var
$myUser = "%blah%";

Still same error.

So, ok, it is the single quote. Move that into the var and...I get no results (already verified it should get results). I'm guessing the single quote must be in the sql when it gets parsed.

Any ideas suggestions?? TIA
StOops
Forum Newbie
Posts: 2
Joined: Tue Jun 11, 2002 1:56 pm

Post by StOops »

Never mind, got it. You don't need the single quotes - teach me to copy and paste from SQLPlus :D
Post Reply