以下是錯誤消息:調用未定義的函數mysql_connect?
Fatal error: Call to undefined function mysql_connect() in /var/www/config.php on line 10
下面是代碼:
<?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";
// 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";
}
?>php
的錯誤是在config.php文件,所以它會比較ü有條理地查看來自該文件的代碼。有可能你只是用不正確的參數調用mysql_connect函數。 – 2010-10-28 15:15:30
你應該清理用戶輸入:http://stackoverflow.com/questions/129677/whats-the-best-method-for-sanitizing-user-input-with-php – 2010-10-28 15:16:53
@laurencek這將產生一個不同的錯誤信息。問題在於該函數根本沒有定義,並不是有一個參數錯配。 – meagar 2010-10-28 15:17:45