【发布时间】:2015-04-13 04:15:00
【问题描述】:
您好,我想知道是否有人可以帮助我。
我试过环顾四周,但我仍然不明白为什么会出现此错误。这是我加载页面时出现的错误:
PHP 致命错误:Can't use function return value in write context in G:\PleskVhosts\clubbit.co.uk\project\emailPassword.php on line 2
第 2 行是:
$_SESSION ('emailPassword') = $_POST ('forgotPasswordForm');
完整的 emailPassword.php 文件:
<?php @session_start(); //make the session remember the users names so they can be inserted on page
$_SESSION ('emailPassword') = $_POST ('forgotPasswordForm');
?>
<?php require_once('Connections/clubbit.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_emailPassword = "-1";
if (isset($_SESSION['emailPassword'])) {
$colname_emailPassword = $_SESSION['emailPassword'];
}
mysql_select_db($database_clubbit, $clubbit);
$query_emailPassword = sprintf("SELECT * FROM users WHERE email = %s", GetSQLValueString($colname_emailPassword, "text"));
$emailPassword = mysql_query($query_emailPassword, $clubbit) or die(mysql_error());
$row_emailPassword = mysql_fetch_assoc($emailPassword);
$totalRows_emailPassword = mysql_num_rows($emailPassword);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
<?php
mysql_free_result($emailPassword);
?>
<?php
if ($totalRows_emailPassword > 0) { //only if an email exists
$from = "support.clubbit.co.uk"; //my email
$email = $_SESSION ('emailPassword'); //user email from form
$subject = "Clubbit Password Request"; //subject
$message = "Your Clubbit password is: ".$row_emailPassword['password']; //display password from recordset here
mail ($email, $subject, $message, "From: ".$from);
}
if ($totalRows_emailPassword > 0) { //if success
echo "Please check your email. Your password has been sent successfully!";
} else { //if fail
echo "Fail - Please try again.";
}
?>
忘记密码表格:
<form ACTION="emailPassword.php" method="POST" name="forgotPasswordForm" id="forgotPasswordForm">
<div>
<input name="email" type="email" required id="email" placeholder="Email" size="45">
<input name="submit" type="submit" class="submit" id="submit" value="Email Password">
</div>
</form>
任何帮助都会很棒!
【问题讨论】:
-
$_SESSION ('emailPassword') = $_POST ('forgotPasswordForm');->$_SESSION ['emailPassword'] = $_POST ['forgotPasswordForm'];简单数组访问 -
天啊,现在感觉好蠢……谢谢。
-
这不是您做错的唯一地方。如果你现在改变这条线,你就知道了
-
是的,我现在可以看到我做错的所有地方,谢谢:)
标签: php database email fatal-error