About PHP

Hi there,

Someone there who knows how to fix this problem.
using PHP, in my .ini file I have the following line:

query = "SELECT * FROM interfaces WHERE intf_id=$key1 ORDER BY intf_code"
(where $key1 had to be variable.)

While scripting I do this:

$key1=5;
$query = get_from_ini(query);
print "$query";

the result of this is a printed line, like;
SELECT * FROM interfaces WHERE intf_id=$key1 ORDER BY intf_code

I expected that the value of $key1 was substituted to $query, so in that case the output line had to be;
SELECT * FROM interfaces WHERE intf_id=5 ORDER BY intf_code

How to get this 'right'

regards

Jan Rutger
:rolleyes:

How does this work for you? Same results?

$query = get_from_ini(query);
$key1=5;
print "$query";

Hi Neo,

it took a while BUT your options did not gave the right result.
Thanks anyway

I used this line:
$query_ = preg_replace ("%KEY$i%", "$key[$i]", $query);

which can be read as:
$query_ = preg_replace ("%KEY1%", "5", SELECT * FROM interfaces WHERE intf_id=KEY1 ORDER BY intf_code
);