How to fetch php tag embeded code from database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

How to fetch php tag embeded code from database?

Post by waseem83 »

Hi i want to fetch a data from database ,I fetched it successfully but it is not working.

The database data is "<? include('contactUs.php');?>"

I fetched it through sql query but page is not including

After fetching i saved it in variable $abc

then i wrote <? echo $abc;?>

In $abc value coming from database is =<? include('contactUs.php');?>

contactUs.php is a separate page that i want to include but it just print <? include('contactUs.php')?> in view source.

Help me please. Thank you in advance
urooj786
Forum Newbie
Posts: 12
Joined: Mon Nov 09, 2009 11:56 pm

Re: How to fetch php tag embeded code from database?

Post by urooj786 »

on which variable u stored fetch result display with field name it 'll show easily

$r=mysql_query("select from table_name");
while($rr=mysql_fetch_array($r))
{
echo $rr[0];
echo $rr[1];
}

OR

$r=mysql_query("select from table_name");
while($rr=mysql_fetch_array($r))
{
echo $rr['field1'];
echo $rr['feild2'];
}
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: How to fetch php tag embeded code from database?

Post by pbs »

I think your local server does not support short PHP tag. So include the php page as given below.

Code: Select all

 
<?php include('contactUs.php'); ?>
 
waseem83
Forum Commoner
Posts: 54
Joined: Tue Jun 23, 2009 3:51 am
Contact:

Re: How to fetch php tag embeded code from database?

Post by waseem83 »

i use this way.

$r=mysql_query("select from table_name");
while($rr=mysql_fetch_array($r))
{
echo $rr['field1'];
echo $rr['feild2'];
}
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: How to fetch php tag embeded code from database?

Post by pbs »

Your select query is wrong. You have not mentioned (*) or field names in query.
urooj786
Forum Newbie
Posts: 12
Joined: Mon Nov 09, 2009 11:56 pm

Re: How to fetch php tag embeded code from database?

Post by urooj786 »

include page as

<? include "xxx.php"; ?>

:)
ctmaster
Forum Newbie
Posts: 7
Joined: Wed Jul 08, 2009 10:45 pm

Re: How to fetch php tag embeded code from database?

Post by ctmaster »

Code: Select all

 
<?php
    $a = "<?php include 'php.php';?>";
    $file = fopen('b.php', 'w');
    fwrite($file, $a);
    include 'b.php';
    unlink('b.php');
?>
 
Post Reply