主题:请问这句php的语法错在哪里?谢谢
开始学做一个PHP网页,用DreamWeaver做。在这一句尝试自己写,然后DW说我mysql_query后面有语法错误,但我就是看了几个小时就想不通,为这一句呆了好久(可能以后还有很多句。。。困难重重),请各位指点一下。 $MM_Username是一个session变量。
[code]
$query_logedMemRec = "SELECT * FROM memberinfo WHERE mi_ID = mysql_fetch_row(mysql_query(SELECT lg_ID FROM logon WHERE lg_username='$MM_Username', $userLogon))";
[/code]
还是附全文好了。$MM_Username 已经在前一个登陆界面赋值。
member.php
[code]
<?php require_once('Connections/userLogon.php'); ?>
<?php
session_start(); //added
// *** Logout the current user.
$FF_Logout = $HTTP_SERVER_VARS['PHP_SELF'] . "?FF_Logoutnow=1";
if (isset($HTTP_GET_VARS['FF_Logoutnow']) && $HTTP_GET_VARS['FF_Logoutnow']=="1") {
session_start();
session_unregister("MM_Username");
session_unregister("MM_UserAuthorization");
$FF_logoutRedirectPage = "logon.php";
// redirect with URL parameters (remove the "FF_Logoutnow" query param).
if ($FF_logoutRedirectPage == "") $FF_logoutRedirectPage = $HTTP_SERVER_VARS['PHP_SELF'];
if (!strpos($FF_logoutRedirectPage, "?") && $HTTP_SERVER_VARS['QUERY_STRING'] != "") {
  $FF_newQS = "?";
  reset ($HTTP_GET_VARS);
  while (list ($key, $val) = each ($HTTP_GET_VARS)) {
    if($key != "FF_Logoutnow"){
      if (strlen($FF_newQS) > 1) $FF_newQS .= "&";
      $FF_newQS .= $key . "=" . urlencode($val);
    }
  }
  if (strlen($FF_newQS) > 1) $FF_logoutRedirectPage .= $FF_newQS;
}
header("Location: $FF_logoutRedirectPage");
exit;
}
mysql_select_db($database_userLogon, $userLogon);
$query_logedMemRec = "SELECT * FROM memberinfo WHERE mi_ID = mysql_fetch_row(mysql_query(SELECT lg_ID FROM logon WHERE lg_username='$MM_Username', $userLogon))"; #problem !
$logedMemRec = mysql_query($query_logedMemRec, $userLogon) or die(mysql_error());
$row_logedMemRec = mysql_fetch_assoc($logedMemRec);
$totalRows_logedMemRec = mysql_num_rows($logedMemRec);
$colname_logonMemRec = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_logonMemRec = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_userLogon, $userLogon);
$query_logonMemRec = sprintf("SELECT * FROM logon WHERE lg_username = '%s'", $colname_logonMemRec);
$logonMemRec = mysql_query($query_logonMemRec, $userLogon) or die(mysql_error());
$row_logonMemRec = mysql_fetch_assoc($logonMemRec);
$totalRows_logonMemRec = mysql_num_rows($logonMemRec);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url]http://www.w3.org/TR/html4/loose.dtd[/url]">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<p>Log on Secceed. This is a member page. <a href="<?php echo $FF_Logout ?>">Log out</a> </p>
<p> </p>
<table width="307" border="0" cellspacing="0">
<tr>
  <td width="157">Surname</td>
  <td width="146"><?php echo $row_logedMemRec['mi_surname']; ?></td>
</tr>
<tr>
  <td>Given Name </td>
  <td><?php echo $row_logedMemRec['mi_givenName']; ?></td>
</tr>
<tr>
  <td> </td>
  <td><?php echo $row_logedMemRec['mi_otherName']; ?></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($logedMemRec);
mysql_free_result($logonMemRec);
?>
[/code]
[code]
$query_logedMemRec = "SELECT * FROM memberinfo WHERE mi_ID = mysql_fetch_row(mysql_query(SELECT lg_ID FROM logon WHERE lg_username='$MM_Username', $userLogon))";
[/code]
还是附全文好了。$MM_Username 已经在前一个登陆界面赋值。
member.php
[code]
<?php require_once('Connections/userLogon.php'); ?>
<?php
session_start(); //added
// *** Logout the current user.
$FF_Logout = $HTTP_SERVER_VARS['PHP_SELF'] . "?FF_Logoutnow=1";
if (isset($HTTP_GET_VARS['FF_Logoutnow']) && $HTTP_GET_VARS['FF_Logoutnow']=="1") {
session_start();
session_unregister("MM_Username");
session_unregister("MM_UserAuthorization");
$FF_logoutRedirectPage = "logon.php";
// redirect with URL parameters (remove the "FF_Logoutnow" query param).
if ($FF_logoutRedirectPage == "") $FF_logoutRedirectPage = $HTTP_SERVER_VARS['PHP_SELF'];
if (!strpos($FF_logoutRedirectPage, "?") && $HTTP_SERVER_VARS['QUERY_STRING'] != "") {
  $FF_newQS = "?";
  reset ($HTTP_GET_VARS);
  while (list ($key, $val) = each ($HTTP_GET_VARS)) {
    if($key != "FF_Logoutnow"){
      if (strlen($FF_newQS) > 1) $FF_newQS .= "&";
      $FF_newQS .= $key . "=" . urlencode($val);
    }
  }
  if (strlen($FF_newQS) > 1) $FF_logoutRedirectPage .= $FF_newQS;
}
header("Location: $FF_logoutRedirectPage");
exit;
}
mysql_select_db($database_userLogon, $userLogon);
$query_logedMemRec = "SELECT * FROM memberinfo WHERE mi_ID = mysql_fetch_row(mysql_query(SELECT lg_ID FROM logon WHERE lg_username='$MM_Username', $userLogon))"; #problem !
$logedMemRec = mysql_query($query_logedMemRec, $userLogon) or die(mysql_error());
$row_logedMemRec = mysql_fetch_assoc($logedMemRec);
$totalRows_logedMemRec = mysql_num_rows($logedMemRec);
$colname_logonMemRec = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_logonMemRec = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_userLogon, $userLogon);
$query_logonMemRec = sprintf("SELECT * FROM logon WHERE lg_username = '%s'", $colname_logonMemRec);
$logonMemRec = mysql_query($query_logonMemRec, $userLogon) or die(mysql_error());
$row_logonMemRec = mysql_fetch_assoc($logonMemRec);
$totalRows_logonMemRec = mysql_num_rows($logonMemRec);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url]http://www.w3.org/TR/html4/loose.dtd[/url]">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<p>Log on Secceed. This is a member page. <a href="<?php echo $FF_Logout ?>">Log out</a> </p>
<p> </p>
<table width="307" border="0" cellspacing="0">
<tr>
  <td width="157">Surname</td>
  <td width="146"><?php echo $row_logedMemRec['mi_surname']; ?></td>
</tr>
<tr>
  <td>Given Name </td>
  <td><?php echo $row_logedMemRec['mi_givenName']; ?></td>
</tr>
<tr>
  <td> </td>
  <td><?php echo $row_logedMemRec['mi_otherName']; ?></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($logedMemRec);
mysql_free_result($logonMemRec);
?>
[/code]