Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP is setting a variable to an array no matter what I do?
    primarykey
    data
    text
    <p>This is the weirdest bug I've ever encountered and I am at wits end here. It just started on the script even know the only thing I changed was running the capitalizing function on the first and last name variables. </p> <p>The problem is with the "$lname" variable. I've got the script in debug, and I have it echoing out "$lname" throughout each process, and it's only after I set it to the _SESSION variable that it changes into an array. Nothing I do seems to work. Everytime the user returns to the form it unsets all the session vars, but I've even tried changing the name of "$_SESSION['reglname']; and I still get the same thing happening. </p> <p>I'm at wits end here, and if you read through this you can see I've tried just about everything to force it through as a string. I guess I can edit the subsequent scripts to account for it being an array, but I'd rather figure out what the hells going on here so I can avoid it in the future! PLEASE HELP!</p> <pre><code>//Start session session_start(); unset($_SESSION['ERRMSG_ARR']); //Include database connection details require_once("$DOCUMENT_ROOT/../SQLlogin.php"); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $fname = clean($_POST['FirstName']); $lname = clean($_POST['LastName']); $email = clean($_POST['Email']); $cemail = clean($_POST['ConfirmEmail']); $bday = clean($_POST['BirthDay']); $bmonth = clean($_POST['BirthMonth']); $byear = clean($_POST['BirthYear']); echo $lname; //Capitalize first and last name $fname = ucwords($fname); $lname = ucwords($lname); //Collate and format birthdate if ($bmonth &lt; 10){ $bdate = clean("0".$bmonth."/".$bday."/".$byear); }else{ $bdate = clean($bmonth."/".$bday."/".$byear); } //Echo out vars to check echo $fname."&lt;br /&gt;".$lname; //Server-side validations if($fname == '' || strlen($fname) &lt; 2 || strlen($fname) &gt; 24 || strpbrk($fname, " ")) { $errmsg_arr[] = '*First name must be greater than 2 characters, less than 24, and contain no spaces!'; $errflag = true; } if($lname == '' || strlen($lname) &lt; 2 || strlen($lname) &gt; 24 || strpbrk($lname, " ")) { $errmsg_arr[] = '*Last name must be greater than 2 characters, less than 24, and contain no spaces!'; $errflag = true; } if(!ereg("[a-zA-Z]+", $fname, $lname)){ $errmsg_arr[] = '*First and last name can contain only letters!'; $errflag = true; } if ($email == '' || strlen($email) &lt; 2 || strlen($email) &gt; 32) { $errmsg_arr[] = '*Email address must be greater than 3 and less than 32 characters!'; $errflag = true; } if ($cemail == '') { $errmsg_arr[] = '*Email address must be greater than 3 and less than 32 characters!'; $errflag = true; } if ($email != $cemail) { $errmsg_arr[] = '*Email addresses do not match!'; $errflag = true; } if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ $errmsg_arr[] = '*The email address entered appears to be invalid. Please enter a valid email address'; $errflag = true; } if($bday == '') { $errmsg_arr[] = '*Birthday field left blank!'; $errflag = true; } if($bmonth == '') { $errmsg_arr[] = '*Birth month field left blank'; $errflag = true; } if($byear == '') { $errmsg_arr[] = '*Birth year field left blank'; $errflag = true; } $year = date(Y); if(($year - $byear) &lt; 18){ $errmsg_arr[] = '*You must be 18 years or older to register as a Hoppr client!'; $errflag = true; } $allowed_age = 18; $bdatecheck = strtotime($byear.'-'.$bmonth.'-'.$bday); $age = (time()-$bdatecheck)/31536000; if($age &gt;= $allowed_age) { }else{ $errmsg_arr[] = '*You must be 18 years or older to register as a Hoppr client!'; $errflag = true; } //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: http://www.thehoppr.com/clients/registration.php"); exit(); } echo $_SESSION['reglname']; //Set registration session vars $_SESSION['regstep'] = (int) 0; $_SESSION['regfname'] = (string) $fname; (string) $_SESSION['reglname'] = (string) $lname; $_SESSION['regemail'] = (string) $email; $_SESSION['regbdate'] = (string) $bdate; echo $_SESSION['reglname']; //Perform the email check query $checkqry = "SELECT * FROM clients WHERE email='".mysql_real_escape_string($email)."'"; $checkresult = mysql_query($checkqry); $checkAry = mysql_fetch_array($checkresult, MYSQL_ASSOC); if (empty($checkAry)){ //No email found, send user to step 2 $_SESSION['regstep'] = (int) 2; }else{ //Dupl email found, check for Hoppr registration $isReg = $checkAry['isReg']; if ($isReg == 0) { global $checkAry; //Email found but not registered. Send user to Facebook merge page $_SESSION['regstep'] = (int) 1; $_SESSION['regfbname'] = $checkAry['firstname']." ".$checkAry['lastname']; $_SESSION['regfbpic'] = $checkAry['imgURL']; $_SESSION['regfbid'] = $checkAry['facebookID']; $_SESSION['regfbbday'] = $checkAry['birthday']; }else{ //Email found and is registered. Ask user for a different email } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload