About PHP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting About PHP
# 1  
Old 12-24-2002
Network 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
Smilie
# 2  
Old 12-24-2002
How does this work for you? Same results?

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

# 3  
Old 01-07-2003
Holliday is over

Hi Neo,

it took a while BUT your options did not gave the right result.
Thanks anyway
# 4  
Old 01-08-2003
I fixed it

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
);
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. What is on Your Mind?

Saturday May 4th the Forums Will Briefly Break Testing PHP 5.6 to PHP 7.0

On Saturday May 4th the forums will briefly break when I switch our Apache PHP 5.6 module to PHP 7.0. Previously, I had two sites set up for testing the migration, but for many reasons, the second site has additional issues unrelated to PHP 7.0 so it is hard to debug on a different site and... (3 Replies)
Discussion started by: Neo
3 Replies

2. Red Hat

Update php 4.3 RPM to php 5.3.3 php

Dear All, My redhat version is: # cat /etc/redhat-release Red Hat Enterprise Linux AS release 4 (Nahant Update 4) # # uname -a Linux cotapplication3.cot.com 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux # I want to update my php from: # php... (1 Reply)
Discussion started by: monojcool
1 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script1.php'); system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script2.php'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies
Login or Register to Ask a Question