Far Cry Posted April 28, 2012 Share Posted April 28, 2012 The following script just validates some form inputs, and then puts any errors inside an array. I get this error: Fatal error: Cannot use [] for reading in C:\xampp\htdocs\Game\includes\validation.php on line 104 I've looked around, and this still does not make any sense to me. public function ValidateEmail($email, $reemail){ /* Sanatize. User filter_var to validate. Make sure both emails match. Check if email already exists or not. */ trim($email); strip_tags($email); mysql_real_escape_string($email); trim($reemail); strip_tags($reemail); mysql_real_escape_string($reemail); if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $this->valid = false; //Line 104 $this->error[] - "The E-Mail that you provided is not valid."; } else { $this->valid = true; } if($email !== $reemail){ $this->valid = false; $this->error[] = "The E-Mail's that you provided do not match."; } else { $this->valid = true; } if(filter_var($email, FILTER_VALIDATE_EMAIL) && $email == $reemail){ $checkmail = mysql_query("SELECT users.email, temp_users.email FROM users, temp_users WHERE email = '$email'"); if(mysql_mum_rows($checkmail) == 1){ // email is found, throw out error $this->valid = false; $this->error[] = "That E-Mail is already in use."; } else { $this->valid = true; } } return $this->error; } Line 104 is commented out. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/261780-cannot-use-for-reading/ Share on other sites More sharing options...
Far Cry Posted April 28, 2012 Author Share Posted April 28, 2012 Hmm :/ Quote Link to comment https://forums.phpfreaks.com/topic/261780-cannot-use-for-reading/#findComment-1341451 Share on other sites More sharing options...
requinix Posted April 28, 2012 Share Posted April 28, 2012 So the line of code is $this->error[] - "The E-Mail that you provided is not valid."; Take a closer look at it. Quote Link to comment https://forums.phpfreaks.com/topic/261780-cannot-use-for-reading/#findComment-1341454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.