需要帮助解密PHP错误消息

AON*_*AON 0 php

如何克服以下错误:

Notice: Use of undefined constant temp_members_db - assumed 'temp_members_db' 
in /var/www/signup_ac.php on line 10 Cannot send Confirmation link to 
your e-mail address
Run Code Online (Sandbox Code Playgroud)

以下是代码:

<?php

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

include('config.php');

// table name
$tbl_name=temp_members_db;

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];

// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: your name <your email>";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
//$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";
$message.="http://localhost/confirmation.php?passkey=$confirm_code";

// send email   
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>
Run Code Online (Sandbox Code Playgroud)

Ign*_*ams 9

要么你忘记了,要么你忘记$了一些引用.


Gum*_*mbo 5

您可能正在使用temp_members_db数组键,但没有正确引用字符串:

$arr[temp_members_db] ? $arr['temp_members_db']
Run Code Online (Sandbox Code Playgroud)

另见为什么$foo[bar]错?:

这是错误的,但它确实有效.原因是此代码具有未定义的常量(bar)而不是字符串('bar'- 注意引号).PHP可能在将来定义常量,不幸的是,这些代码具有相同的名称.它的工作原理是因为PHP自动将一个裸字符串(一个与任何已知符号不对应的不带引号的字符串)转换为包含裸字符串的字符串.例如,如果没有已命名的已定义常量bar,那么PHP将替换为字符串'bar'并使用它.