That doesn't work as the new string already is like select * FROM `table`
where id='2' order by name assuming $value was 2...
Hatem Ben [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
Greetings all,
I got a headache doing this, i need to get vars inside an sql query. For
example :
At 13:54 12-6-03, you wrote:
I got a headache doing this, i need to get vars inside an sql query. For
example :
$query = select * FROM `table` where id='$value' order by name;
preg_match_all(/^('\$(.*)')/si, $query,$matches);
That doesn't work as the new string already is like select * FROM
Oh, ok this is how i want to do it exactly :
query.php
?php
$query = select * FROM `table` where id='$value' order by name;
?
parse.php
?php
$fcontents = join('' , file('query.php'));
preg_match_all(/^('\$(.*)')/si, $fcontents,$matches);
print_r($matches)
?
Thanks
Sorry this is more correct :
-- starting query.php
select * FROM `table` where id='$value' order by name
-- ending query.php
Hatem Ben [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
Oh, ok this is how i want to do it exactly :
query.php
?php
$query
Hi,
I'll join the conversation, because I have a similar problem.
PHP interpolates variable values in strings if these are enclosed in
double quotes:
e.g.,
$string = select * FROM `table` where id='$value' order by name;
PHP does not interpolate variables contained in strings delimited
[snip]
$string = select * FROM `table` where id='$value' order by name;
[/snip]
I know it ain't pretty, but the coding style we have accepted is
this
$string = select * FROM `table` where id = ' . $value . ' order by
name ;
or (we requite caps on reserved words)...
$string = SELECT *
PROTECTED]
Subject: RE: [PHP] Re: Vars inside an sql query [Regular expression
question]
Hi,
I'll join the conversation, because I have a similar problem.
PHP interpolates variable values in strings if these are enclosed in
double quotes:
e.g.,
$string = select * FROM `table` where id='$value
inside an sql query [Regular expression
question]
[snip]
$string = select * FROM `table` where id='$value' order by name;
[/snip]
I know it ain't pretty, but the coding style we have accepted is
this
$string = select * FROM `table` where id = ' . $value . ' order by
name ;
or (we
8 matches
Mail list logo