LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 04-02-2005, 11:16 PM   #1
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:


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, 06:37 AM   #2
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, 07:35 AM   #3
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


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 02:15 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 02:19 AM
Regexp problem eremit Programming 6 06-23-2005 06:48 AM
regexp help ... pld Programming 1 03-15-2005 03:45 PM
perl regexp problem raven Programming 4 03-21-2004 11:49 PM

All times are GMT -5. The time now is 04:22 AM.

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