LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 04-03-2005, 12:16 AM   #1
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Rep: Reputation: 15
PHP regexp problem


Hi all,

I have a small problem with regular expression with PHP.
I want to retrive the all data from mySQL found at the beginning of field.

In mySQL field there is some data like:

Abdul
Abdf
Atif
Ramesh
Tone
Jon

I was trying to retrieve from the following query

$what = “Ab”;
$sql_query = "SELECT *FROM table WHERE '^$what' regexp UserName and Level =2 ORDER BY UserName";

return blank

But not working without any error warring.
But if I am giving the full value for $what variable it is working with one record.

$what = “Abdul”;
$sql_query = "SELECT *FROM table WHERE '^$what' regexp UserName and Level =2 ORDER BY UserName";
return only Abdul


I will be very approcate if any one bring me in good way.

Thank You
 
Old 04-03-2005, 07:37 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
It might help if you put the command in the correct order

This line works on my system, but swapping the field and regexp returns null:

select * from table where UserName regexp '^Ab';

After that, if you're still having trouble, make sure PHP is replacing the embedded variable in the query string properly.
 
Old 04-03-2005, 08:35 AM   #3
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Original Poster
Rep: Reputation: 15
HI CroMagnon,

Thank you for your reply.

Really it was waht i was needed. it is working perfactly.

Thank You
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
regexp help cliff76 Linux - Newbie 3 03-07-2008 03:15 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 03:19 AM
Regexp problem eremit Programming 6 06-23-2005 07:48 AM
regexp help ... pld Programming 1 03-15-2005 04:45 PM
perl regexp problem raven Programming 4 03-22-2004 12:49 AM


All times are GMT -5. The time now is 07:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration