我试图弄清楚为什么我不断收到此错误:
PHP 致命错误:在第 102 行调用 /home/lear/public_html/storescripts/my_ipn.php 中的未定义函数 uniqueName()
第 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);
}