0
在第一个php代码!$fgmembersite->CheckLogin()
完美的作品。也在接下来的HTML代码<?= $fgmembersite->UserFullName(); ?>!
完美的作品。但在第二个PHP它不会正常工作。我在代码中做错了什么? if($row['name']=="$fgmembersite->UserFullName()")
获取登录用户名用php从数据库
<?PHP
require_once("./include/membersite_config.php");
if(!$fgmembersite->CheckLogin())
{
$fgmembersite->RedirectToURL("login.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Home page</title>
<link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">
</head>
<body>
<div id='fg_membersite_content'>
<h2>Home Page</h2>
Welcome back <?= $fgmembersite->UserFullName(); ?>!
</div>
</body>
<?php
include("db.php");
$select=mysql_query("select * from commenttable");
while($row=mysql_fetch_array($select))
{
if($row['name']=="$fgmembersite->UserFullName()")
{
echo "<div id='sty'>";
echo "<img src='files/fav icon.png'"."' width='50px' height='50px' align='left' />";
echo "<div id='nameid'>".$row['name']."</div>";
echo "<div id='msgid'>".$row['message']."</div>";
echo "</div><br />";
}else{
ob_start();
echo "<div id='sty'>";
echo "<img src='files/fav icon.png'"."' width='50px' height='50px' align='left' />";
echo "<div id='nameid'>".$row['name']."</div>";
echo "<div id='msgid'>".$row['message']."</div>";
echo "</div><br />";
ob_end_clean();
}
}
?>
请妥善格式化你的问题。查看预览并确保它在发布之前很好地显示。阅读:http://meta.stackexchange.com/editing-help – light
删除''$ fgmembersite-> UserFullName()“引号''' – max