[PHP] Vars inside an sql query [Regular expression question] - Again
I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem
Re: [PHP] Vars inside an sql query [Regular expression question]- Again
preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); ^^ you don't allow any character between start of the string and single quote. preg_match_all(/^.*('\$(.*)')/si, $fcontents,$matches); Hatem Ben wrote: I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Vars inside an sql query [Regular expression question] - Again
Right then. Here's what I have done, and it works: ===Contents of query.txt=== ?php $fcontents = QUERY select * FROM `table` where id='$value' order by name QUERY; ? ===End Contents of query.txt=== Then: ===Contents of parse.php=== ?php include('query.txt'); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? ===End Contents of parse.php=== Now, whereas this works, I am still looking for a way to store and interpolate variables contained in query.txt without the kludge of having to embed the assignment of $fcontents inside the file as above :-( Have fun, Monu -Original Message- From: Hatem Ben [mailto:[EMAIL PROTECTED] Sent: 12 June 2003 14:59 To: [EMAIL PROTECTED] Subject: [PHP] Vars inside an sql query [Regular expression question] - Again I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars inside an sql query [Regular expression question] - Again
It's not working also - Original Message - From: Marek Kilimajer [EMAIL PROTECTED] To: Hatem Ben [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, June 12, 2003 5:23 PM Subject: Re: [PHP] Vars inside an sql query [Regular expression question] - Again preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); ^^ you don't allow any character between start of the string and single quote. preg_match_all(/^.*('\$(.*)')/si, $fcontents,$matches); Hatem Ben wrote: I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars inside an sql query [Regular expression question] - Again
Well, it's finally working, but still very confusing ... thanks all ?php $fcontents = join('' , file('query.txt')); preg_match_all('/(\'\$(.*)\')/si', $fcontents,$matches); print_r($matches) ? Regards, Hatem - Original Message - From: Hatem Ben [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Marek Kilimajer [EMAIL PROTECTED] Sent: Thursday, June 12, 2003 4:35 PM Subject: Re: [PHP] Vars inside an sql query [Regular expression question] - Again It's not working also - Original Message - From: Marek Kilimajer [EMAIL PROTECTED] To: Hatem Ben [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, June 12, 2003 5:23 PM Subject: Re: [PHP] Vars inside an sql query [Regular expression question] - Again preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); ^^ you don't allow any character between start of the string and single quote. preg_match_all(/^.*('\$(.*)')/si, $fcontents,$matches); Hatem Ben wrote: I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars inside an sql query [Regular expression question]- Again
Now I noticed you did not escape backslash that was supposed to escape the dolar sign. preg_match_all(/^.*('\\\$(.*)')/si, $fcontents,$matches); ^ ^ Hatem Ben wrote: Well, it's finally working, but still very confusing ... thanks all ?php $fcontents = join('' , file('query.txt')); preg_match_all('/(\'\$(.*)\')/si', $fcontents,$matches); print_r($matches) ? Regards, Hatem - Original Message - From: Hatem Ben [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Marek Kilimajer [EMAIL PROTECTED] Sent: Thursday, June 12, 2003 4:35 PM Subject: Re: [PHP] Vars inside an sql query [Regular expression question] - Again It's not working also - Original Message - From: Marek Kilimajer [EMAIL PROTECTED] To: Hatem Ben [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, June 12, 2003 5:23 PM Subject: Re: [PHP] Vars inside an sql query [Regular expression question] - Again preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); ^^ you don't allow any character between start of the string and single quote. preg_match_all(/^.*('\$(.*)')/si, $fcontents,$matches); Hatem Ben wrote: I'm asking again the same question, coz i guess my question wasn't clear. i just need to retreive vars inside query.txt, my regular expression seems to be correct for me, but i don't find why it doesn't wrk -- Starting query.txt select * FROM `table` where id='$value' order by name -- Ending query.txt -- Starting parse.php ?php $fcontents = join('' , file('query.txt')); preg_match_all(/^('\$(.*)')/si, $fcontents,$matches); print_r($matches) ? - Ending parse.php rewriting query is another question, that i agree also. Thanks Hatem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php