警告:請求mysql_query():6是不是在C一個有效的MySQL鏈路資源:... \ mysql_helper.php上線94
$con = mysql_connect($GLOBALS['mysql_host'], $GLOBALS['mysql_username'], $GLOBALS['mysql_password']) or die(mysql_error());
$db = mysql_select_db($GLOBALS['mysql_database']) or die(mysql_error($con));
$username=sanitize_mysql($username);
$password=sanitize_mysql($password);
$email=sanitize_mysql($email);
if(check_exists("users", "username", $username) == FALSE){
$query = "INSERT INTO users VALUES('".$username."','".$password."','".$email."','".$status."','".$reg_date."','".$own_ref_id."','')";
$result = mysql_query($query,$con) or die(mysql_error($con));
return TRUE;
} else {
return FALSE;
}
mysql_close($con);
作品在建立這樣的(複製/粘貼),所有其他功能
這是check_exists
function check_exists($table,$specifier,$value)
{
$con = mysql_connect($GLOBALS['mysql_host'], $GLOBALS['mysql_username'], $GLOBALS['mysql_password']) or die(mysql_error());
$db = mysql_select_db($GLOBALS['mysql_database']) or die(mysql_error($con));
$query = "SELECT * FROM ".$table." WHERE ".$specifier." = '".$value."'";
$erg = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($erg)) {
mysql_close($con);
return TRUE;
}
mysql_close($con);
return FALSE;
}
執行'sanitize_mysql()'或'check_exists()'touch'$ con'? – eggyal
我添加了check_exists –