0

Here's a snippet of my code:

<?
include("include/session.php");
//include("forum/global.php");

$con = mysql_connect($dbhost,$dbuser,$dbpass);

$time = time();
$date = date("Y-n-j H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$email = $_POST['email'];
$lastname = ucwords($_POST['lastname']);
$firstname = ucwords($_POST['firstname']);
$firstinitial = $firstname[0];
$username = $firstinitial."_".$lastname;
$pass = $_POST['password'];

// MYBB

function generate_salt()
{
    return random_str(8);
}

function salt_password($password, $salt)
{
    return md5(md5($salt).$password);
}

$md5pass = md5($pass);
$salt = generate_salt();
$salted_pass = salt_password($md5pass, $salt);

$loginkey = random_str(50);

I get this error:

Fatal error: Call to undefined function random_str() in /home/myusername/public_html/thefile.php on line 20

Line 20 is the return random_str() line.
Can someone help me solve my problem please?

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by richieking
0

If you check line 21 of the code you pasted above, there is a call to the function random_str(). Where did you define this function ? By defining, it means where is the implementation of the function ? eg

function random_str($iLength)
{
  // code for generating a string containing $iLength random characters 
  // return the generated string
}

So, define your function somewhere in that file or perhaps in the global.php (which is commented out ?!?) then your error should vanish

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.