problem with fetching data from mysql using two file
Posted: Sat May 14, 2011 1:08 am
i am trying to fetch some information from database and show it in some other page , i know scope of a variable limited within function if its not global and superglobal....but how to pass the info outside .... here is my code..the function showingdata is in xyz class...similarly dblink(database connection and selection here) and realescapestring
function showingdta($cuid) /*user info*/
{
$table2="member_info";
if($this->dblink()==TRUE)
{
$query='SELECT * FROM '. $table2 .' WHERE EMAIL= "'.$this->realescapestring($cuid).'"';
$result=mysql_query($query,$this->conn_link) or die("prob");
$info=mysql_fetch_array($result);
if (mysql_error())
{ print "Database ERROR: " . mysql_error(); }
header("Content-type: $info");
echo $info;
}
else
{return FALSE;}
}
in show.php file
<?php
session_start();
include_once("info.php");
$biglife= new xyz;
$cuid=100011;
$biglife->showingdta($cuid);
echo "<table>";
echo "<tr>";
echo "<td>Name:</td>";
echo "<td> " . $info['FIRST_NAME']. " </td>";
echo "</tr>";
echo "</table>";
?>
function showingdta($cuid) /*user info*/
{
$table2="member_info";
if($this->dblink()==TRUE)
{
$query='SELECT * FROM '. $table2 .' WHERE EMAIL= "'.$this->realescapestring($cuid).'"';
$result=mysql_query($query,$this->conn_link) or die("prob");
$info=mysql_fetch_array($result);
if (mysql_error())
{ print "Database ERROR: " . mysql_error(); }
header("Content-type: $info");
echo $info;
}
else
{return FALSE;}
}
in show.php file
<?php
session_start();
include_once("info.php");
$biglife= new xyz;
$cuid=100011;
$biglife->showingdta($cuid);
echo "<table>";
echo "<tr>";
echo "<td>Name:</td>";
echo "<td> " . $info['FIRST_NAME']. " </td>";
echo "</tr>";
echo "</table>";
?>