Page 1 of 1

How to fetch php tag embeded code from database?

Posted: Mon Nov 09, 2009 11:59 pm
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

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

Posted: Tue Nov 10, 2009 2:19 am
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'];
}

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

Posted: Tue Nov 10, 2009 2:27 am
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'); ?>
 

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

Posted: Tue Nov 10, 2009 2:31 am
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'];
}

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

Posted: Tue Nov 10, 2009 2:43 am
by pbs
Your select query is wrong. You have not mentioned (*) or field names in query.

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

Posted: Tue Nov 10, 2009 3:26 am
by urooj786
include page as

<? include "xxx.php"; ?>

:)

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

Posted: Tue Nov 10, 2009 3:57 am
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');
?>