Lamez Posted December 19, 2009 Share Posted December 19, 2009 I am working on my RegisterUser function. The function checks the fields for errors, if errors do exist then it adds it to the errorArray, if not it continues. It will return true if no errors are present, and it will return false if errors do exist. Well I am not getting anything in return. I have no idea why. Here is the function(s) <?php include("db-config.php"); function clean($str){ $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } function checkExist($table, $col, $var){ $table = clean($table); $col = clean($col); $var = clean($var); $q = mysql_query("SELECT * FROM $table WHERE $col = '$var' LIMIT 1")or die("Function Check Exist: ".mysql_error()); $n = mysql_num_rows($q); $n = 0; if($n == 0){ return false; }else if($n > 0){ return true; } } function RegisterUser($table, $email, $email2, $first, $last, $pass, $pass2){ $table = clean($table); $email = strtolower(clean($email)); $email2 = strtolower(clean($email2)); $first = clean($first); $last = clean($last); $pass = clean($pass); $pass2 = clean($pass2); if(!empty($email) && !empty($email2)){ if(checkMatch($email, $email2) == true){ if(checkEmail($email) == true){ if(checkExist($table, "email", $email) == false){ $db_email = $email; }else{ addError("email", "Email already exist."); addError("email2", "Email already exist."); } }else{ addError("email", "Email is invalid."); addError("email2", "Email is invalid."); } }else{ addError("email", "Emails did not match."); addError("email2", "Emails did not match."); } }else{ if(empty($email)){ addError("email", "Email field is empty"); } if(empty($email2)){ addError("email2", "Email field is empty"); } } if(checkMatch($pass, $pass2) == true){ if(checkPass($pass) == true && checkPass($pass2)){ $db_pass = $pass; }else{ if(checkPass($pass) == false){ addError("pass", "Password is too small."); } if(checkPass($pass2) == false){ addError("pass2", "Password is too small."); } } }else{ addError("pass", "Passwords did not match."); addError("pass2", "Passwords did not match."); } if(!empty($first)){ $db_first = strtolower($first); }else{ addError("first", "First name is empty."); } if(!empty($last)){ addError("last", "Last name is empty."); }else{ $db_last = strtolower($last); } if(checkForErrors($_SESSION['errorArray']) == true){ return false; }else{ $id = mysql_num_rows(mysql_query("SELECT * FROM $table")); mysql_query("INSERT INTO $table (id, email, first, last, password) VALUES ('$id', '$db_email', '$db_first', '$db_last', '$db_pass')"); return true; } } function checkEmail($email){ if(preg_match("/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0){ return true; }else{ return false; } } function checkPass($pass){ $pass = strlen($pass); $required = 6; if($pass == $required){ return true; }else{ return false; } } function checkMatch($str1, $str2){ if($str1 === $str2){ return true; }else{ return false; } } function addError($field, $error){ $_SESSION['errorArray'] = array($field => $error); } function getError($field){ if(!$_SESSION['errorArray'][$field]){ return $_SESSION['errorArray'][$field]; }else{ return ' '; } } function checkForErrors($array){ if(isset($array)){ return true; }else{ return false; } } ?> Here is the page that is suppose to handle the output" <?php $path = "../../"; include($path."core/main.php"); $type = $_POST['type']; if($type == 0){ $e = $_POST['e']; $e2 = $_POST['e']; $f = $_POST['f']; $l = $_POST['l']; $p = $_POST['p']; $p2 = $_POST['p2']; echo RegisterUser($_people, $e, $e2, $f, $l, $p, $p2); }else{ header("Location: ".$_main_error); } ?> Any thoughts would be great! -Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 19, 2009 Share Posted December 19, 2009 Echoing a FALSE value does not necessarily display anything. Use var_dump() to debug what your function returns. Your addError function is overwriting the $_SESSION['errorArray'] variable each time it is called, so it will only have the last entry. You need to use - $_SESSION['errorArray'][] = array($field => $error); Also, use real variable names in your code (not just single letters.) A week or two from now when you look at your code, you won't remember what your main code means and people in help forums won't even attempt to help troubleshoot if the problem involves figuring out what those single letter variable names mean in your code. Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/#findComment-980472 Share on other sites More sharing options...
Lamez Posted December 19, 2009 Author Share Posted December 19, 2009 Thanks for the help, I will make those changes. Also can you tell me more about these "real variables". If you are talking about the $_people and the $_main_error variables. Those are all defined in a file called "constant_variables" So I can change one file, and the whole system changes, without opening six of seven different pages. Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/#findComment-980558 Share on other sites More sharing options...
mrMarcus Posted December 19, 2009 Share Posted December 19, 2009 he's talking about: <?php $e = $_POST['e']; $e2 = $_POST['e']; $f = $_POST['f']; $l = $_POST['l']; $p = $_POST['p']; $p2 = $_POST['p2']; echo RegisterUser($_people, $e, $e2, $f, $l, $p, $p2); ?> to me, e, e2, f, l, p, p2 are just alphanumeric values .. no more, no less. nobody, including yourself in a few short weeks, can just look at: RegisterUser($_people, $e, $e2, $f, $l, $p, $p2); and know what those arguments are/do. "real variable names" as PFMaBiSmAd said are variables which use a name directly associated to the value of that variable, ie. if you had a variable that was going to hold the total of an equation, for example, don't just name it $t .. name it $total. get it? or $total_of_a_plus_b (which is unnecessary, but i'm trying to give a relevant example). what this does is let's you know, simply by reading the name of the variable, more or less - and in some cases exactly - what the variable does/holds. Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/#findComment-980577 Share on other sites More sharing options...
Lamez Posted December 19, 2009 Author Share Posted December 19, 2009 Okay so I noticed the array that is being returned is huge, that is because I sent it multiple times. So I tried adding this: <?php if(isset($_SESSION['errorArray'])){ empty($_SESSION['errorArray']); } ?> but the array still looks like this array(360) { [0]=> array(1) { ["email"]=> string(20) "Email field is empty" } [1]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [2]=> array(1) { ["pass"]=> string(22) "Password is too small." } [3]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [4]=> array(1) { ["first"]=> string(20) "First name is empty." } [5]=> array(1) { ["email"]=> string(20) "Email field is empty" } [6]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [7]=> array(1) { ["pass"]=> string(22) "Password is too small." } [8]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [9]=> array(1) { ["first"]=> string(20) "First name is empty." } [10]=> array(1) { ["email"]=> string(20) "Email field is empty" } [11]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [12]=> array(1) { ["pass"]=> string(22) "Password is too small." } [13]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [14]=> array(1) { ["first"]=> string(20) "First name is empty." } [15]=> array(1) { ["email"]=> string(20) "Email field is empty" } [16]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [17]=> array(1) { ["pass"]=> string(22) "Password is too small." } [18]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [19]=> array(1) { ["first"]=> string(20) "First name is empty." } [20]=> array(1) { ["email"]=> string(20) "Email field is empty" } [21]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [22]=> array(1) { ["pass"]=> string(22) "Password is too small." } [23]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [24]=> array(1) { ["first"]=> string(20) "First name is empty." } [25]=> array(1) { ["email"]=> string(20) "Email field is empty" } [26]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [27]=> array(1) { ["pass"]=> string(22) "Password is too small." } [28]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [29]=> array(1) { ["email"]=> string(20) "Email field is empty" } [30]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [31]=> array(1) { ["pass"]=> string(24) "Passwords did not match." } [32]=> array(1) { ["pass2"]=> string(24) "Passwords did not match." } [33]=> array(1) { ["first"]=> string(20) "First name is empty." } [34]=> array(1) { ["last"]=> string(19) "Last name is empty." } [35]=> array(1) { ["email"]=> string(20) "Email field is empty" } [36]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [37]=> array(1) { ["pass"]=> string(22) "Password is too small." } [38]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [39]=> array(1) { ["first"]=> string(20) "First name is empty." } [40]=> array(1) { ["email"]=> string(20) "Email field is empty" } [41]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [42]=> array(1) { ["pass"]=> string(22) "Password is too small." } [43]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [44]=> array(1) { ["first"]=> string(20) "First name is empty." } [45]=> array(1) { ["email"]=> string(20) "Email field is empty" } [46]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [47]=> array(1) { ["pass"]=> string(22) "Password is too small." } [48]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [49]=> array(1) { ["first"]=> string(20) "First name is empty." } [50]=> array(1) { ["email"]=> string(20) "Email field is empty" } [51]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [52]=> array(1) { ["pass"]=> string(22) "Password is too small." } [53]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [54]=> array(1) { ["first"]=> string(20) "First name is empty." } [55]=> array(1) { ["email"]=> string(20) "Email field is empty" } [56]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [57]=> array(1) { ["pass"]=> string(22) "Password is too small." } [58]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [59]=> array(1) { ["first"]=> string(20) "First name is empty." } [60]=> array(1) { ["email"]=> string(20) "Email field is empty" } [61]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [62]=> array(1) { ["pass"]=> string(22) "Password is too small." } [63]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [64]=> array(1) { ["first"]=> string(20) "First name is empty." } [65]=> array(1) { ["email"]=> string(20) "Email field is empty" } [66]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [67]=> array(1) { ["pass"]=> string(22) "Password is too small." } [68]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [69]=> array(1) { ["first"]=> string(20) "First name is empty." } [70]=> array(1) { ["email"]=> string(20) "Email field is empty" } [71]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [72]=> array(1) { ["pass"]=> string(22) "Password is too small." } [73]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [74]=> array(1) { ["first"]=> string(20) "First name is empty." } [75]=> array(1) { ["email"]=> string(20) "Email field is empty" } [76]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [77]=> array(1) { ["pass"]=> string(22) "Password is too small." } [78]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [79]=> array(1) { ["first"]=> string(20) "First name is empty." } [80]=> array(1) { ["email"]=> string(20) "Email field is empty" } [81]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [82]=> array(1) { ["pass"]=> string(22) "Password is too small." } [83]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [84]=> array(1) { ["first"]=> string(20) "First name is empty." } [85]=> array(1) { ["email"]=> string(20) "Email field is empty" } [86]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [87]=> array(1) { ["pass"]=> string(22) "Password is too small." } [88]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [89]=> array(1) { ["first"]=> string(20) "First name is empty." } [90]=> array(1) { ["email"]=> string(20) "Email field is empty" } [91]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [92]=> array(1) { ["pass"]=> string(22) "Password is too small." } [93]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [94]=> array(1) { ["first"]=> string(20) "First name is empty." } [95]=> array(1) { ["email"]=> string(20) "Email field is empty" } [96]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [97]=> array(1) { ["pass"]=> string(22) "Password is too small." } [98]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [99]=> array(1) { ["first"]=> string(20) "First name is empty." } [100]=> array(1) { ["email"]=> string(20) "Email field is empty" } [101]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [102]=> array(1) { ["pass"]=> string(22) "Password is too small." } [103]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [104]=> array(1) { ["first"]=> string(20) "First name is empty." } [105]=> array(1) { ["email"]=> string(20) "Email field is empty" } [106]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [107]=> array(1) { ["pass"]=> string(22) "Password is too small." } [108]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [109]=> array(1) { ["first"]=> string(20) "First name is empty." } [110]=> array(1) { ["email"]=> string(20) "Email field is empty" } [111]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [112]=> array(1) { ["pass"]=> string(22) "Password is too small." } [113]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [114]=> array(1) { ["first"]=> string(20) "First name is empty." } [115]=> array(1) { ["email"]=> string(20) "Email field is empty" } [116]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [117]=> array(1) { ["pass"]=> string(22) "Password is too small." } [118]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [119]=> array(1) { ["first"]=> string(20) "First name is empty." } [120]=> array(1) { ["email"]=> string(20) "Email field is empty" } [121]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [122]=> array(1) { ["pass"]=> string(22) "Password is too small." } [123]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [124]=> array(1) { ["first"]=> string(20) "First name is empty." } [125]=> array(1) { ["email"]=> string(20) "Email field is empty" } [126]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [127]=> array(1) { ["pass"]=> string(22) "Password is too small." } [128]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [129]=> array(1) { ["first"]=> string(20) "First name is empty." } [130]=> array(1) { ["email"]=> string(20) "Email field is empty" } [131]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [132]=> array(1) { ["pass"]=> string(22) "Password is too small." } [133]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [134]=> array(1) { ["first"]=> string(20) "First name is empty." } [135]=> array(1) { ["email"]=> string(20) "Email field is empty" } [136]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [137]=> array(1) { ["pass"]=> string(22) "Password is too small." } [138]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [139]=> array(1) { ["first"]=> string(20) "First name is empty." } [140]=> array(1) { ["email"]=> string(20) "Email field is empty" } [141]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [142]=> array(1) { ["pass"]=> string(22) "Password is too small." } [143]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [144]=> array(1) { ["first"]=> string(20) "First name is empty." } [145]=> array(1) { ["email"]=> string(20) "Email field is empty" } [146]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [147]=> array(1) { ["pass"]=> string(22) "Password is too small." } [148]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [149]=> array(1) { ["first"]=> string(20) "First name is empty." } [150]=> array(1) { ["email"]=> string(20) "Email field is empty" } [151]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [152]=> array(1) { ["pass"]=> string(22) "Password is too small." } [153]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [154]=> array(1) { ["first"]=> string(20) "First name is empty." } [155]=> array(1) { ["email"]=> string(20) "Email field is empty" } [156]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [157]=> array(1) { ["pass"]=> string(22) "Password is too small." } [158]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [159]=> array(1) { ["first"]=> string(20) "First name is empty." } [160]=> array(1) { ["email"]=> string(20) "Email field is empty" } [161]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [162]=> array(1) { ["pass"]=> string(22) "Password is too small." } [163]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [164]=> array(1) { ["first"]=> string(20) "First name is empty." } [165]=> array(1) { ["email"]=> string(20) "Email field is empty" } [166]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [167]=> array(1) { ["pass"]=> string(22) "Password is too small." } [168]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [169]=> array(1) { ["first"]=> string(20) "First name is empty." } [170]=> array(1) { ["email"]=> string(20) "Email field is empty" } [171]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [172]=> array(1) { ["pass"]=> string(22) "Password is too small." } [173]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [174]=> array(1) { ["first"]=> string(20) "First name is empty." } [175]=> array(1) { ["email"]=> string(20) "Email field is empty" } [176]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [177]=> array(1) { ["pass"]=> string(22) "Password is too small." } [178]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [179]=> array(1) { ["first"]=> string(20) "First name is empty." } [180]=> array(1) { ["email"]=> string(20) "Email field is empty" } [181]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [182]=> array(1) { ["pass"]=> string(22) "Password is too small." } [183]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [184]=> array(1) { ["first"]=> string(20) "First name is empty." } [185]=> array(1) { ["email"]=> string(20) "Email field is empty" } [186]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [187]=> array(1) { ["pass"]=> string(22) "Password is too small." } [188]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [189]=> array(1) { ["first"]=> string(20) "First name is empty." } [190]=> array(1) { ["email"]=> string(20) "Email field is empty" } [191]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [192]=> array(1) { ["pass"]=> string(22) "Password is too small." } [193]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [194]=> array(1) { ["first"]=> string(20) "First name is empty." } [195]=> array(1) { ["email"]=> string(20) "Email field is empty" } [196]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [197]=> array(1) { ["pass"]=> string(22) "Password is too small." } [198]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [199]=> array(1) { ["first"]=> string(20) "First name is empty." } [200]=> array(1) { ["email"]=> string(20) "Email field is empty" } [201]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [202]=> array(1) { ["pass"]=> string(22) "Password is too small." } [203]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [204]=> array(1) { ["first"]=> string(20) "First name is empty." } [205]=> array(1) { ["email"]=> string(20) "Email field is empty" } [206]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [207]=> array(1) { ["pass"]=> string(22) "Password is too small." } [208]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [209]=> array(1) { ["first"]=> string(20) "First name is empty." } [210]=> array(1) { ["email"]=> string(20) "Email field is empty" } [211]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [212]=> array(1) { ["pass"]=> string(22) "Password is too small." } [213]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [214]=> array(1) { ["first"]=> string(20) "First name is empty." } [215]=> array(1) { ["email"]=> string(20) "Email field is empty" } [216]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [217]=> array(1) { ["pass"]=> string(22) "Password is too small." } [218]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [219]=> array(1) { ["first"]=> string(20) "First name is empty." } [220]=> array(1) { ["email"]=> string(20) "Email field is empty" } [221]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [222]=> array(1) { ["pass"]=> string(22) "Password is too small." } [223]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [224]=> array(1) { ["first"]=> string(20) "First name is empty." } [225]=> array(1) { ["email"]=> string(20) "Email field is empty" } [226]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [227]=> array(1) { ["pass"]=> string(22) "Password is too small." } [228]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [229]=> array(1) { ["first"]=> string(20) "First name is empty." } [230]=> array(1) { ["email"]=> string(20) "Email field is empty" } [231]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [232]=> array(1) { ["pass"]=> string(22) "Password is too small." } [233]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [234]=> array(1) { ["first"]=> string(20) "First name is empty." } [235]=> array(1) { ["email"]=> string(20) "Email field is empty" } [236]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [237]=> array(1) { ["pass"]=> string(22) "Password is too small." } [238]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [239]=> array(1) { ["first"]=> string(20) "First name is empty." } [240]=> array(1) { ["email"]=> string(20) "Email field is empty" } [241]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [242]=> array(1) { ["pass"]=> string(22) "Password is too small." } [243]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [244]=> array(1) { ["first"]=> string(20) "First name is empty." } [245]=> array(1) { ["email"]=> string(20) "Email field is empty" } [246]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [247]=> array(1) { ["pass"]=> string(22) "Password is too small." } [248]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [249]=> array(1) { ["first"]=> string(20) "First name is empty." } [250]=> array(1) { ["email"]=> string(20) "Email field is empty" } [251]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [252]=> array(1) { ["pass"]=> string(22) "Password is too small." } [253]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [254]=> array(1) { ["first"]=> string(20) "First name is empty." } [255]=> array(1) { ["email"]=> string(20) "Email field is empty" } [256]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [257]=> array(1) { ["pass"]=> string(22) "Password is too small." } [258]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [259]=> array(1) { ["first"]=> string(20) "First name is empty." } [260]=> array(1) { ["email"]=> string(20) "Email field is empty" } [261]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [262]=> array(1) { ["pass"]=> string(22) "Password is too small." } [263]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [264]=> array(1) { ["first"]=> string(20) "First name is empty." } [265]=> array(1) { ["email"]=> string(20) "Email field is empty" } [266]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [267]=> array(1) { ["pass"]=> string(22) "Password is too small." } [268]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [269]=> array(1) { ["first"]=> string(20) "First name is empty." } [270]=> array(1) { ["email"]=> string(20) "Email field is empty" } [271]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [272]=> array(1) { ["pass"]=> string(22) "Password is too small." } [273]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [274]=> array(1) { ["first"]=> string(20) "First name is empty." } [275]=> array(1) { ["email"]=> string(20) "Email field is empty" } [276]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [277]=> array(1) { ["pass"]=> string(22) "Password is too small." } [278]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [279]=> array(1) { ["first"]=> string(20) "First name is empty." } [280]=> array(1) { ["email"]=> string(20) "Email field is empty" } [281]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [282]=> array(1) { ["pass"]=> string(22) "Password is too small." } [283]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [284]=> array(1) { ["first"]=> string(20) "First name is empty." } [285]=> array(1) { ["email"]=> string(20) "Email field is empty" } [286]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [287]=> array(1) { ["pass"]=> string(22) "Password is too small." } [288]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [289]=> array(1) { ["first"]=> string(20) "First name is empty." } [290]=> array(1) { ["email"]=> string(20) "Email field is empty" } [291]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [292]=> array(1) { ["pass"]=> string(22) "Password is too small." } [293]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [294]=> array(1) { ["first"]=> string(20) "First name is empty." } [295]=> array(1) { ["email"]=> string(20) "Email field is empty" } [296]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [297]=> array(1) { ["pass"]=> string(22) "Password is too small." } [298]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [299]=> array(1) { ["first"]=> string(20) "First name is empty." } [300]=> array(1) { ["email"]=> string(20) "Email field is empty" } [301]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [302]=> array(1) { ["pass"]=> string(22) "Password is too small." } [303]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [304]=> array(1) { ["first"]=> string(20) "First name is empty." } [305]=> array(1) { ["email"]=> string(20) "Email field is empty" } [306]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [307]=> array(1) { ["pass"]=> string(22) "Password is too small." } [308]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [309]=> array(1) { ["first"]=> string(20) "First name is empty." } [310]=> array(1) { ["email"]=> string(20) "Email field is empty" } [311]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [312]=> array(1) { ["pass"]=> string(22) "Password is too small." } [313]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [314]=> array(1) { ["first"]=> string(20) "First name is empty." } [315]=> array(1) { ["email"]=> string(20) "Email field is empty" } [316]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [317]=> array(1) { ["pass"]=> string(22) "Password is too small." } [318]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [319]=> array(1) { ["first"]=> string(20) "First name is empty." } [320]=> array(1) { ["email"]=> string(20) "Email field is empty" } [321]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [322]=> array(1) { ["pass"]=> string(22) "Password is too small." } [323]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [324]=> array(1) { ["first"]=> string(20) "First name is empty." } [325]=> array(1) { ["email"]=> string(20) "Email field is empty" } [326]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [327]=> array(1) { ["pass"]=> string(22) "Password is too small." } [328]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [329]=> array(1) { ["first"]=> string(20) "First name is empty." } [330]=> array(1) { ["email"]=> string(20) "Email field is empty" } [331]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [332]=> array(1) { ["pass"]=> string(22) "Password is too small." } [333]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [334]=> array(1) { ["first"]=> string(20) "First name is empty." } [335]=> array(1) { ["email"]=> string(20) "Email field is empty" } [336]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [337]=> array(1) { ["pass"]=> string(22) "Password is too small." } [338]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [339]=> array(1) { ["first"]=> string(20) "First name is empty." } [340]=> array(1) { ["email"]=> string(20) "Email field is empty" } [341]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [342]=> array(1) { ["pass"]=> string(22) "Password is too small." } [343]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [344]=> array(1) { ["first"]=> string(20) "First name is empty." } [345]=> array(1) { ["email"]=> string(20) "Email field is empty" } [346]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [347]=> array(1) { ["pass"]=> string(22) "Password is too small." } [348]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [349]=> array(1) { ["first"]=> string(20) "First name is empty." } [350]=> array(1) { ["email"]=> string(20) "Email field is empty" } [351]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [352]=> array(1) { ["pass"]=> string(22) "Password is too small." } [353]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [354]=> array(1) { ["first"]=> string(20) "First name is empty." } [355]=> array(1) { ["email"]=> string(20) "Email field is empty" } [356]=> array(1) { ["email2"]=> string(20) "Email field is empty" } [357]=> array(1) { ["pass"]=> string(22) "Password is too small." } [358]=> array(1) { ["pass2"]=> string(22) "Password is too small." } [359]=> array(1) { ["first"]=> string(20) "First name is empty." } } Also when I use my function getError, it is not returning anything, any ideas why? Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/#findComment-980579 Share on other sites More sharing options...
Lamez Posted December 19, 2009 Author Share Posted December 19, 2009 he's talking about: <?php $e = $_POST['e']; $e2 = $_POST['e']; $f = $_POST['f']; $l = $_POST['l']; $p = $_POST['p']; $p2 = $_POST['p2']; echo RegisterUser($_people, $e, $e2, $f, $l, $p, $p2); ?> to me, e, e2, f, l, p, p2 are just alphanumeric values .. no more, no less. nobody, including yourself in a few short weeks, can just look at: RegisterUser($_people, $e, $e2, $f, $l, $p, $p2); and know what those arguments are/do. "real variable names" as PFMaBiSmAd said are variables which use a name directly associated to the value of that variable, ie. if you had a variable that was going to hold the total of an equation, for example, don't just name it $t .. name it $total. get it? or $total_of_a_plus_b (which is unnecessary, but i'm trying to give a relevant example). what this does is let's you know, simply by reading the name of the variable, more or less - and in some cases exactly - what the variable does/holds. I gotcha, but that code is obvious, when you look at that code, you can tell where it has been defined. I don't think that is a problem as of now. Quote Link to comment https://forums.phpfreaks.com/topic/185682-maybe-i-am-missing-something-function-not-returning-any-values/#findComment-980580 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.