我試圖找出爲什麼我不斷收到此錯誤:未定義功能PHP MYSQL
PHP Fatal error: Call to undefined function uniqueName() in/home/lear/public_html/storescripts/my_ipn.php on line 102
線102是
if (! uniqueName($username))
require_once 'connect_to_mysql.php';
//now to always get unique username
$username = substr($payer_email, 0, strpos($payer_email, '@'));
if (! uniqueName($username))
{
$username = makeUniqueName($username);
}
//function to check if is the existing username
function isUniqueName($username)
{
$sql = mysql_query("SELECT username FROM transactions WHERE username='$username'");
$numRows = mysql_num_rows($sql);
if ($numRows > 0)
{
return false;
}
return true;
}
//function to generate new unique username
function makeUniqueName($username)
{
//serch username string for number at the end
//regexp makes sure all preceeding zeroes go to first match group
if (preg_match('/^(\S*?0*)?(\d+?)$/', $username, $match))
{
//we got digit from the end of string, just add 1 to the digit
$username = $match[1] . ($match[2] + 1);
}
else
{
//no digit at the end of string, just add digit 1 at the end
$username = $username . 1;
}
if (isUniqueName($username))
{
return $username;
}
return makeUniqueName($username);
}
錯誤消息比這更明顯嗎? – Barmar
投票結束。這是太具體,沒有任何其他人使用。 –
我並不是想成爲更尊重的人,但是當有人試圖學習這種類型的迴應時會非常沮喪。 – Chris