Cetanu Posted June 30, 2009 Share Posted June 30, 2009 I was wondering why this will not cooperate: <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); // check if the username is taken $check = "select id from $table where username = '".$_POST['username']."';"; $qry = mysql_query($check) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows != 0) { echo "Sorry, there the username {$_POST['username']} is already taken.<br>"; echo "<a href=register.html>Try again</a>"; exit; } if({$_POST['password']} != {$_POST['confirmnewpassword']}){ echo ("The two passwords must match."); } else { // insert the data $insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['email']."')") or die("Could not insert data because ".mysql_error()); // print a success message echo "Your user account has been created!<br>"; echo "Now you can <a href=user_login.php>log in</a>"; } ?> I know it has something to do with this section: } if({$_POST['password']} != {$_POST['confirmnewpassword']}){ echo ("The two passwords must match."); } Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/ Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 What do you mean by, "not cooperate"...? Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866405 Share on other sites More sharing options...
patrickmvi Posted June 30, 2009 Share Posted June 30, 2009 What error are you getting from this and where? Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866433 Share on other sites More sharing options...
Cetanu Posted June 30, 2009 Author Share Posted June 30, 2009 The script just will not do anything. There's no error, it just loads to this page (registration.php) and goes white. I want that statement to confirm that the people are confirming their password. This attaches to a registration form, so there are Username, Password, Confirm Password, and Email. I want that little section to confirm that password = confirmnewpassword (or in this case the IF statement). Thanks. Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866438 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Sounds like you have a fatal error. Add these lines directly after your opening PHP tags: ini_set ("display_errors", "1"); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866440 Share on other sites More sharing options...
HuggieBear Posted June 30, 2009 Share Posted June 30, 2009 You don't need the curly brackets either. if($_POST['password'] != $_POST['confirmnewpassword']){ echo ("The two passwords must match."); } Rich Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866444 Share on other sites More sharing options...
Cetanu Posted June 30, 2009 Author Share Posted June 30, 2009 Hey it works! What is the error reporting thing, Maq? (What does it do?) Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866456 Share on other sites More sharing options...
HuggieBear Posted June 30, 2009 Share Posted June 30, 2009 What is the error reporting thing, Maq? (What does it do?) It means that all the errors should show up in the browser. This should make debugging easier. Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866458 Share on other sites More sharing options...
Maq Posted June 30, 2009 Share Posted June 30, 2009 Hey it works! What is the error reporting thing, Maq? (What does it do?) You can read the documentation here: error_reporting. Link to comment https://forums.phpfreaks.com/topic/164250-insert-into-script-help/#findComment-866461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.