phpperson Posted October 15, 2013 Share Posted October 15, 2013 So i'm making a register page and it keeps saying sorry we could not register you. So if someone can look and see if I did something wrong that would be great <?php require 'datebase.inc.php'; require'thecore.inc.php'; if(!loggedin()) { if(isset($_POST['username'])&&isset($_POST['surname'])&&isset($_POST['password'])&&isset($_POST['password_again'])&&isset($_POST['firstname'])) { $Username = $_POST['username']; $firstname = $_POST['firstname']; $Surname = $_POST['surname']; $Password = $_POST['password']; $password_hash = md5($Password); $password_again = $_POST['password_again']; if (!empty($Username)&&!empty($Surname)&&!empty($Password)&&!empty($password_again)&&!empty($firstname)){ if ($Password!==$password_again) { echo 'Password does not match'; }else{ $query = "SELECT `username` FROM `users` WHERE `username` = '$Username'"; $query_run = mysql_query($query); if(mysql_num_rows($query_run)==1) { echo 'The username '.$Username.' already exists.'; }else{ $query = "INSERT INTO `users` VALUES ('','".mysql_real_escape_string($Username)."','".mysql_real_escape_string($password_hash)."','".mysql_real_escape_string($firstname)."','".mysql_real_escape_string($Surname)."',)"; if($query_run = mysql_query($query)) { header('Location:ui.php'); }else{ echo 'sorry we could not register you'; } } } }else{ echo 'Fill in the fields'; } } } ?> <form action="register.php" method="POST"> <input type="text" name="username" placeholder="Username..." value="<?php ?>"> <input type="text" name="surname" placeholder=" Surname... " value="<?php ?>"><br><br> <input type="password" name="password" placeholder=" Password..."><br><br> <input type="password" name="password_again" placeholder=" Password again..."><br><br> <input type="text" name="firstname" placeholder=" firstname..."><br><br> <input type="submit" Value="Register"> </form> Link to comment https://forums.phpfreaks.com/topic/282974-help/ Share on other sites More sharing options...
jcbones Posted October 15, 2013 Share Posted October 15, 2013 }else{ //debugging echo mysql_error(); //end debugging echo 'sorry we could not register you'; } Link to comment https://forums.phpfreaks.com/topic/282974-help/#findComment-1453947 Share on other sites More sharing options...
phpperson Posted October 15, 2013 Author Share Posted October 15, 2013 }else{ //debugging echo mysql_error(); //end debugging echo 'sorry we could not register you'; } Now it says 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 ')' at line 1 Link to comment https://forums.phpfreaks.com/topic/282974-help/#findComment-1453948 Share on other sites More sharing options...
gizmola Posted October 15, 2013 Share Posted October 15, 2013 Right, in your sql statement at the end, you have this: .... mysql_real_escape_string($Surname)."',)"; You have to at minimum, remove that last comma -- SQL does not allow you to have stray commas like that. .... mysql_real_escape_string($Surname)."')"; Link to comment https://forums.phpfreaks.com/topic/282974-help/#findComment-1453951 Share on other sites More sharing options...
phpperson Posted October 15, 2013 Author Share Posted October 15, 2013 Right, in your sql statement at the end, you have this: .... mysql_real_escape_string($Surname)."',)"; You have to at minimum, remove that last comma -- SQL does not allow you to have stray commas like that. .... mysql_real_escape_string($Surname)."')"; it worked thanks Link to comment https://forums.phpfreaks.com/topic/282974-help/#findComment-1453956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.