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
How to fetch php tag embeded code from database?
Moderator: General Moderators
Re: How to fetch php tag embeded code from database?
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'];
}
$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?
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?
i use this way.
$r=mysql_query("select from table_name");
while($rr=mysql_fetch_array($r))
{
echo $rr['field1'];
echo $rr['feild2'];
}
$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?
Your select query is wrong. You have not mentioned (*) or field names in query.
Re: How to fetch php tag embeded code from database?
include page as
<? include "xxx.php"; ?>

<? include "xxx.php"; ?>
Re: How to fetch php tag embeded code from database?
Code: Select all
<?php
$a = "<?php include 'php.php';?>";
$file = fopen('b.php', 'w');
fwrite($file, $a);
include 'b.php';
unlink('b.php');
?>