spamoom Posted September 2, 2007 Share Posted September 2, 2007 I have this function, it shows when i have errors but for some reason is never able to reach the insert query.. here is the code. I suspect it is a typo, please could you have a look for me as I have been searching for over an hour and cant find anything <?php function register($username, $password, $password_conf, $email, $email_conf) { if (eregi('^[[:alnum:]\.\'\-]{4,30}$', stripslashes(trim($username))) ) { $query = "SELECT member_username FROM member WHERE member_username = '$username'"; $result = @$db->query($query); $num = @$db->count($result); if ($num> 0) { $errors[] = '<font color="red">The username you have chosen has already been taken, please try again.</font>'; } } else { $errors[] = '<font color="red">Please provide a valid username between 4 and 30 characters.</font>'; } if (!empty($email)) { if ($email != $email_conf) { $errors[] = '<font color="red">The email addresses you have entered do not match.</font>'; } if (!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($email)) )) { $errors[] = '<font color="red">Please provide a valid email address.</font>'; } } else { $errors[] = '<font color="red">Please provide an email.</font>'; } if (!empty($password)) { if ($password != $password_conf) { $errors[] = '<font color="red">The passwords you have entered do not match.</font>'; } else { $password = md5($password); } } else { $errors[] = '<font color="red">Please provide a password.</font>'; } if (!isset($errors)) { $query = "INSERT INTO member (member_username, member_email, member_password, member_joindate) VALUES ('$username', '$email', '$password', '".date('d-m-Y')."')"; echo $query; $result = @mysql_query($query); if (mysql_affected_rows() == 1) { // Send the E-Mail $body = "Thank You for registering on The Revision Shop:\n\n"; $body .= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?p=activate&a=" . mysql_insert_id() . "&b=$password"; mail($email, 'Registration Confirmation On The Revision Shop', $body, 'From: noreply@therevisionshop.co.uk'); // Show thank you message return 'Sucessfully Registered, Please check your mail box for the activation email'; } else { return '<font color="red">You could not be registered, please contact sam@samjordan.co.uk for help.</font>'; } } else { $err = '<h3>Error!</h3> The following error(s) occured:<br />'; foreach ($errors as $msg) { $err .= " - <font color='red'>$msg</font><br />\n"; } return $err; } } ?> Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted September 2, 2007 Share Posted September 2, 2007 Is there more code above this code? Because i don't see a MySQL Connect or a file including it Quote Link to comment Share on other sites More sharing options...
spamoom Posted September 2, 2007 Author Share Posted September 2, 2007 The mysql works fine, I have a login & logout script working. It is just that the script never reaches the insert statment. I have even tried putting echo "AKDSOAWKDPAWKPDKAWJDAWJODJPWJPJ"; and it does not show at all anywhere in the script expect at the beginning =/ Quote Link to comment Share on other sites More sharing options...
trq Posted September 2, 2007 Share Posted September 2, 2007 Your code is pretty hard to follow as the indentation doesn't seem to have any consistancy. teh first things I would try though would be removing all ocurrances of the @ error supressor. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted September 2, 2007 Share Posted September 2, 2007 why don't you take out parts of it out and test it? YOu don't need the whole code to test it out. Maybe you'll find one error is somehow screwing up the code. You must take the "@"s out. It makes all the errors not shown. - which is bad at this time. For instance, no error is shown but the script is stopped... :-\ Quote Link to comment Share on other sites More sharing options...
spamoom Posted September 2, 2007 Author Share Posted September 2, 2007 Thanks for the replys guys I recieved this nice error after removing the @'s Fatal error: Call to a member function query() on a non-object in C:\Users\SpaM!\Desktop\localhost\therevisionshop\app\framework\functions.php on line 44 So in otherwords... I forgot this global $db; stupid me Quote Link to comment 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.