Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embedded PHP not working 1

Status
Not open for further replies.

maslett

Technical User
Mar 11, 2004
121
GB
Hi.

After years of laboriously updating the html on my website I decided to make it database driven (using mysql). It works well but I can't get embedded php to work.

I have a database entry that contains this...
Code:
<a href="geo.php?map=found">Found</a> (23)<br>
<a href="geo.php?map=notfound">Not Found</a> (5)
<?php echo "hello world";?>

...but the php bit doesn't work.

If you look at the second box on the right here (where it says 'Found and Not Found') - I was expecting the above php to echo 'hello world' - but it doesn't. Looking at the page source showed that the php is not being parsed properly.

So, basically - I have a php driven website where I'd like to embed php into the database entries. But currently the php aint working.

Kind regards,
Matt
 
Looking at the page source showed that the php is not being parsed properly
so it might be your PHP then !
Can you post the error message ?
 
that's a bit curious. this normally happens when you have not hooked your web server up to php properly.

can you tell us what OS you are using, what webserver, what flavour of php (version and integration method)?
 
Hi

jpadie said:
this normally happens when you have not hooked your web server up to php properly.
maslett said:
I have a database entry that contains this...
I would say, that happens when a string containing PHP code is read from the database then simply output.

Feherke.
 
Whooops! I'd completely forgotton about this thread - sorry to everyone who replied, it was rude of me.

To answer some questions from above...

OS: Linux 2.6.24.5 x86_64

PHP: 5.2.6 (integration method?)

Webserver (from phpinfo): Apache/2.2.11 (Unix) PHP/4.4.9 mod_ssl/2.2.11 OpenSSL/0.9.8c mod_fastcgi/2.4.6 Phusion_Passenger/2.1.3 DAV/2 SVN/1.4.2

The rest of the php on the site runs fine. Here's the output of the page source which isn't working:

Code:
<p class="boxtitle">Found and Not Found</p>
<p><a href="geo.php?map=found">Found</a> (57)<br>
<a href="geo.php?map=notfound">Not Found</a> (6)
[b]<?php echo "hello world";?>[/b]</p>

Feherke said:
I would say, that happens when a string containing PHP code is read from the database then simply output.
I would say you're right - hence no error message. I presumed the webserver would see the php and process it normally...

jpadie said:
Feherke,

you may well be right!

...you may be wrong! I'm no Linux guru but I'm no Linux numpty either (except for this problem) ;)
 
Whoops2!

maslett said:
...you may be wrong! I'm no Linux guru but I'm no Linux numpty either (except for this problem) ;)

I visited the link in Feherks's footer about learning Linux, then I read jpadie's comment and thought he was insinuating I should learn Linux - which he/she wasn't.

Jeez - I'm really putting my foot in it today...
 
Take a look here:

Code contained in a string from whatever source DB text file etc.. needs to be eval'd to get executed.

Code in the string must be valid PHP. Lines terminated by semi colons etc...


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Bingo! Thanks vacunita - that worked.

For the record...

This DIDN'T work:

mysqlrecord
Code:
some html code
more html code
<php some php code;?>

PHP code
Code:
echo $mysqlrecord;

This DID work:

mysqlrecord
Code:
?>
some html code
more html code
<php some php code;

PHP code
Code:
eval ('$mysqlrecord');

In the code that DID work - I had to close the php tags so the html ran correctly - then re-open the php tags for the php code to run - the eval() statement automatically closes the php tags again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top