I am tryng to write a small function that will extract pagecontent from a database and i am having problems with it.
I have checked and the dbconnect function, dbselect function are all working fine. Here is the code
I want to call this function at the top of each page and supply a filename like thisPHP Code:
#
#Function for getting page content from database
function pagecontent($filename) {
include ("config.php");
dbconnect();
dbselect("$dbname");
$sql=mysql_query("SELECT * FROM sitecontent WHERE filename='$filename'");
$row = mysql_fetch_array($sql);
$pid=$row["pid"];
$pagetitle=$row["pagetitle"];
$bodytext=$row["bodytext"];
$section=$row["section"];
$pageheading=$row["pageheading"];
$filename=$row["filename"];
return $pagetitle;
return $bodytext;
return $section;
return $pageheading;
return $filename;
}// end function getpagecontent
The code stops to work only when I make it a function ..I really would not like to write all that code at the beginning of each page .. Any ideas why these values will not get returned by the function ?PHP Code:pagecontent("homepage");
echo "$bodytext";
echo"<h4>$pageheading</h4>";
Thanks in advance






Bookmarks