dadamssg Posted March 26, 2009 Share Posted March 26, 2009 writing a register script and im checking if the username and email they typed in already exists, if it does put an error message in an array, then on the form output those errors...i used the same method and it works but now its not. it just displays "array" instead of whats in the array part in the register script /* check whether email already exists */ $cxn = mysqli_connect($host,$user,$passwd,$dbname) or die("Couldn't connect"); $sql = "SELECT email FROM Member WHERE email = '$email'"; $result = mysqli_query($cxn,$sql) or die("Couldn't execute select query."); $num = mysqli_num_rows($result); if ($num > 0) { $alert[] = "There is already an account under $email.<br>"; extract($_POST); include("register_form.php"); exit(); } /* check whether login name already exists */ $sql = "SELECT loginName FROM Member WHERE loginName = '$username'"; $result = mysqli_query($cxn,$sql) or die("Couldn't execute select query."); $num = mysqli_num_rows($result); if ($num > 0) { $alert[] = "$username is already in use. Select another Username.<br>"; extract($_POST); include("register_form.php"); exit(); } and the part in displaying the form and error messages if set if(isset($alert)) { echo "$alert<br>"; } Link to comment https://forums.phpfreaks.com/topic/151180-solved-trouble-outputting-an-array/ Share on other sites More sharing options...
dadamssg Posted March 26, 2009 Author Share Posted March 26, 2009 oh forgot this part in the register script...kinda important haha if(@is_array($alert)) { $aler_t = ""; foreach($alert as $value) { $aler_t .= $value; } extract($_POST); include("register_form.php"); exit(); } Link to comment https://forums.phpfreaks.com/topic/151180-solved-trouble-outputting-an-array/#findComment-794175 Share on other sites More sharing options...
dadamssg Posted March 26, 2009 Author Share Posted March 26, 2009 nevermind...i realized i was just checking two things and scratched the array and just used seperate variables..thanks anyway! Link to comment https://forums.phpfreaks.com/topic/151180-solved-trouble-outputting-an-array/#findComment-794183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.