-
Posts
1,686 -
Joined
-
Last visited
Never
Posts posted by Lamez
-
-
I have the same problem.
-
no I do, I have working pages that communicate with the database, and they are in sub folders as well.
Like this:
/ (works)
/members (works)
/admin (does not work)
/admin/mod (does not work)
I am so lost!
-
Hello, I am sick of getting this error. I will post it below, let me first explain how I get the error to appear. When I create a file in a sub-folder, and execute it, I get the error. However, I have a sub-folder with a script in it and it works just fine. I also tried to make a link to call a function, and I get the same error. Here is the error:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/krazypickem/core/includes/functions.php on line 8Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /var/www/krazypickem/core/includes/functions.php on line 8
Warning: mysql_query() [function.mysql-query]: Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/krazypickem/core/includes/functions.php on line 167
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/krazypickem/core/includes/functions.php on line 167
Any ideas?
P.S. the line it is talking about is a query that has worked before, on a different page.
-
So it is. Also, sorry about posting in the wrong board. I forgot there was a Sql board. +1 for being a noob.
-
This insert query looks to be alright, however I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, online) VALUES ('0', '8', 'nothing@poop.com', 'first', 'last', 'a3' at line 1
Here is the actually query:
<?php //This is only a snippet function makeKey($id){ $key .= $id.rand(0, 10); //To Be Unique for($j=0; $j<=3; $j++){ $key .= rand(11, 20); } for($k=0; $k<=3; $k++){ $key .= rand(21, 30); } return $key; } $key = makeKey($id); mysql_query(" INSERT INTO ".TBL_PEOPLE." (id, level, email, first, last, password, activated, key, online) VALUES ('$id', '$level', '$db_email', '$db_first', '$db_last', '$db_pass', '0', '$key', '0') ")or die(mysql_error()); ?>
Any ideas? Maybe I am just tired.
-
I love the pear library. Here is more information:
-
Thank you so much, that fixed everything! I am new to arrays, and the manual did not solve my problems. Thanks again!
-
Question, does this look right?
array(6) { [0]=> array(1) { ["email"]=> string(21) "Email field is empty." } [1]=> array(1) { ["email2"]=> string(21) "Email field is empty." } [2]=> array(1) { ["pass"]=> string(24) "Password field is empty." } [3]=> array(1) { ["pass2"]=> string(24) "Password field is empty." } [4]=> array(1) { ["first"]=> string(20) "First name is empty." } [5]=> array(1) { ["last"]=> string(19) "Last name is empty." } }
I did this to get that information:
<?php var_dump($_SESSION['errorArray']); ?>
Here is the function that adds the values to the array
<?php function addError($field, $error){ if(!array_key_exists($field, $error)){ $_SESSION['errorArray'][] = array($field => $error); } } ?>
Does all that look right to you guys?
-
just run it as a form, and make a page with a mysql delete query.
-
that is a snippet of the code. You don't want the whole code.
-
I would create a table with the actual word, and the hash. Then match hashes and return the raw word.
-
Okay so what I am trying to do is call a certain value out of an array, which is stored in a $_SESSION variable (which is also an array).
The array in question is my errorArray, and in the registration process, if an error occurs, I add the error to the errorArray.
That part works just fine, it is just getting the value out.
Here is what I have so far:
<?php function getError($field){ return $_SESSION['errorArray'][$field]; } //example echo getError("email"); ?>
This returns nothing. Any ideas?
-Thanks! (again.)
-
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.
-
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!
-
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.
-
in your if statements change it from an '=' to '=='.
The if statement is returning false, and your last echo is showing the variables untouched.
-
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!
-
Thorpe, the rows are suppose to be unique, if you function is more efficient, then I will use it, regardless.
Also, I have echoed out the POST values, and they do return with the expected values. I do believe it is the function. I think it is time for a re-write.
-Thanks guys!
-
Interesting thorpe, but I don't want to know how many rows exist, I just want to know if one exist. So what I have now seems sufficient.
-
define global variables. Also, any help would be appreciated!
-
Yes I caught that as well, I have changed it. I have altered the functions page to this:
<?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, $first, $last, $pass1, $pass2){ $email = clean($email); $first = clean($first); $last = clean($last); $pass1 = clean($pass); $pass2 = clean($pass2); $check = checkEmail($email); $error = "Reg:"; if($pass1 === $pass2){ $error .= "0"; }else{ $error .= "1"; } if($check == true){ $check = checkExist($table, "email", $email); if($check == false){ $error .= "0"; }else if($check == true){ $error .= "1"; } }else if($check == false){ $error .= "2"; } $first = strtolower($first); $last = strtolower($last); $pass = md5($id).sha1($pass1).md5($first.$last); $id = mysql_query("SELECT * FROM $table")or die ("ID Query: ".mysql_error()); $id = mysql_num_rows($id) or die (mysql_error()); if($error == "Reg:"){ mysql_query("INSERT INTO $table (id, email, first, last, password) VALUES ('".$id."', '".$email."', '".$first."', '".$last."', '".$pass."')")or die("Function Check Register: ".mysql_error()); return 0; }else{ return $error; } } function checkEmail($email){ if(preg_match("/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0){ $pass = true; }else{ $pass = false; } return $pass; } ?>
Looks good to me, I also get no MySQL errors! However I have encountered another, annoying, problem.
The page that processes the information does not work all of a sudden, I have no idea why. I get no output what so ever, here is the page.
<?php $path = "../../"; include($path."core/main.php"); $type = $_POST['type']; if($type == 0){ $e = $_POST['e']; $f = $_POST['f']; $l = $_POST['l']; $p = $_POST['p']; $p2 = $_POST['p2']; $check = RegisterUser($_people, $e, $f, $l, $p, $p2); if($check == 0){ echo "User Added."; }else{ //handleError($check); echo "Error!"; } echo $check; }else if($type == 1){ //add later. }else{ header("Location: ".$_main_error); } ?>
I am lost at this point.
-
Further note:
I changed this:
<?php $id = mysql_query("SELECT * FROM $_people")or die ("ID Query: ".mysql_error()); ?>
to this:
<?php $id = mysql_query("SELECT * FROM people")or die ("ID Query: ".mysql_error()); ?>
and the error was depleted. So I found the problem, but when I echo out $_people (outside of the function, but on the same file), I get what I wanted. I wonder if I need to add the $_people into the function variables, and declare it when I need use the function? Any ideas?
-
Then look up MySQL insert queries, and things revolving that matter. They will help a ton
-
Hoped I helped. Mark as solved!
Why am I getting this error? Does not make sense.
in PHP Coding Help
Posted
I was trying to spear you guys, but since it is needed here is the index that is located in my "administration" directory:
here is the main.php
Last but not least, the functions.php (the mac daddy)
There is two more pages that are very important, but I don't think they have anything to do with my problem. Do you guys see any errors? I am lost.