سلام

ممنون از راهنماییتون کد زیر رو مشاهده کنید
کد PHP:
function pagemaker($pagename)
{
$filename="$pagename";


$page='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
    font-size: 10px;
    font-family: Tahoma;
}
-->
</style>
</head>

<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0" background="images/bg.png">
  <tr>
    <td valign="top"><table width="946" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="130" background="images/header.png">&nbsp;</td>
      </tr>
    </table>
      <table width="946" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="281" height="38"><?php include("menu.php"); ?></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="726" rowspan="2" valign="top" bgcolor="#EEEEEE">
              <?php
              
              
include("data.php");
              
        
        
        
        
$select=mysql_query("select * form post where pagename=$pagename");
            
$data=mysql_fetch_array($select);
            
$pagename=$data[pagename];
            
//-------------------------------------------------------------
              
$select=mysql_query("select * from post where pagename=$pagename");
              
$data=mysql_fetch_array($select);
              
?>
              <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="29" align="center" valign="middle" background="images/mainpostbg/a.png"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="right"><?php  echo $data[subject]; ?></td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td height="100" valign="top" background="images/mainpostbg/b.png"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="right"><?php  echo $data[text];; ?></td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td height="20" background="images/mainpostbg/c.png">&nbsp;</td>
                </tr>
                </table>
                
                
                
                
                <br /></td>
              <td width="220" align="center" valign="top"><?php  include("rightmenu.php"); ?></td>
            </tr>
            
            <tr>
              <td align="center" valign="top">&nbsp;</td>
            </tr>
          </table></td>
        </tr>
     
        <tr>
          <td height="30" background="images/footerbg.png">&nbsp;</td>
        </tr>   
      </table>
  
      
      </td>
  </tr>
</table>

</body>
</html>

';

include("");
$maker=fopen("../posts/$filename","w")or exit("Unable to open file!");
     fwrite($maker,$page);
fclose($maker);
}
مشکل من در قسمتی هست که اطلاعات رو میخواد از دیتابیس بخونه !
باید متغیر در داخل 2 تا '' قرار بگیره که وقتی اجرا میشه پیغام خطا نشون میده

کد زیر رو برای نمونه مشاهد کنید
کد PHP:
 $select=mysql_query("select * form post where pagename='$pagename'"); 
اگر من $pagename رو در داخل '' قرار بدم خطا صادر میشه !
میخوام این مشکلم رفع بشه

تشکر