Modernvox Posted January 25, 2010 Share Posted January 25, 2010 "error somewhere"; outputs correctly, but nothing is added to the database at all? <?php if ((isset($_POST['submit'])) && (!empty($_POST['regname'])) && (!empty($_POST['regstate'])) && (!empty($_POST['regcity'])) && (!empty($_POST['regemail'])) && (!empty($_POST['username'])) && (!empty($_POST['password'])) && (!empty($_POST['confirmpass']))) { $reg_name= $_POST['regname']; $reg_state= $_POST['regstate']; $reg_city= $_POST['regcity']; $reg_email= $_POST['regemail']; $reg_username= $_POST['username']; $reg_password= $_POST['password']; $reg_confirmpass= $_POST['confirmpass']; $database= register; $dbx =mysql_connect('', '', ''); if (!$dbx) { die('Could not connect: ' . mysql_error()); } else mysql_select_db($database) or die( "Unable to select database"); $insert_query = 'INSERT INTO users (reg_name, reg_state, reg_city, reg_email, reg_username, reg_password, ) VALUES ( "' . $_POST['regstate'] . '", "' . $_POST['regcity'] . '", "' . $_POST['regemail'] . '", "' . $_POST['username'] . '", "' . $_POST['password'] . '" )'; mysql_query($insert_query); } else echo "error somewhere"; ?> My Form <form action="reg_success.php" method="POST"> <table> <tr> <td><font face= "tahoma" size= "2">Name</font></td> <td><input type= "text" name= "regname" size= "35" /></td> <td><br><br></td> </tr> <tr> <td><font face= "tahoma" size= "2">State</font></td> <td><input type= "text" name= "regstate" size= "35" /></td> <td><br><br></td> </tr> </tr> <td><font face= "tahoma" size= "2">City</font></td> <td><input type="text" name= "regcity" size= "35" /></td> <td><br><br></td> </tr> <tr> <td><font face= "tahoma" size= "2">Email</font></td> <td><input type="text" name= "regemail" size= "35" /></td> </tr> <tr> <td><br></td> </tr> <tr> <td><br></td> </tr> <tr> <td><br></td> </tr> <tr> <td><br></td> </tr> <tr> <td><font face= "tahoma" size= "2">Choose a username</font></td> <td><input type= "text" name= "username" size "35"/></td> </tr> <tr> <td><br></td> </tr> <tr> <td><font face= "tahoma" size= "2">Choose a password</font></td> <td><input type= "pass" name= "password" size "35"/></td> </tr> <tr> <td><font face= "tahoma" size= "2">Confirm password</font></td> <td><input type= "pass" name= "confirmpass" size "35"/></td> </tr> <tr> <td><br></td> </tr> <tr> <td><br></td> </tr> </table> <center><input type="submit" name="submit" value= "register" /></center> </form> Link to comment https://forums.phpfreaks.com/topic/189681-almost-there-but-no-values-are-being-stored-is-it-my-php-or-db-syntax/ Share on other sites More sharing options...
Modernvox Posted January 25, 2010 Author Share Posted January 25, 2010 Any takers??? Link to comment https://forums.phpfreaks.com/topic/189681-almost-there-but-no-values-are-being-stored-is-it-my-php-or-db-syntax/#findComment-1001082 Share on other sites More sharing options...
greatstar00 Posted January 25, 2010 Share Posted January 25, 2010 u have extract comma after reg_password at last column, there shouldnt be extra comma plus there are 6 columns, and 5 values passed in column not matching values Link to comment https://forums.phpfreaks.com/topic/189681-almost-there-but-no-values-are-being-stored-is-it-my-php-or-db-syntax/#findComment-1001083 Share on other sites More sharing options...
Modernvox Posted January 25, 2010 Author Share Posted January 25, 2010 u have extract comma after reg_password at last column, there shouldnt be extra comma plus there are 6 columns, and 5 values passed in column not matching values Does nothing.... <php if ((isset($_POST['submit'])) && (!empty($_POST['regname'])) && (!empty($_POST['regstate'])) && (!empty($_POST['regcity'])) && (!empty($_POST['regemail'])) && (!empty($_POST['username'])) && (!empty($_POST['password'])) && (!empty($_POST['confirmpass']))) { $reg_name= $_POST['regname']; $reg_state= $_POST['regstate']; $reg_city= $_POST['regcity']; $reg_email= $_POST['regemail']; $reg_username= $_POST['username']; $reg_password= $_POST['password']; $reg_confirmpass= $_POST['confirmpass']; $database= register; $dbx =mysql_connect('localhost', 'root', ""); if (!$dbx) { die('Could not connect: ' . mysql_error()); } else mysql_select_db($database) or die( "Unable to select database"); $insert_query = 'INSERT INTO users (reg_name, reg_state, reg_city, reg_email, reg_username, reg_password, ) VALUES ( "' . $_POST['regname'] . '", "' . $_POST['regstate'] . '", "' . $_POST['regcity'] . '", "' . $_POST['regemail'] . '", "' . $_POST['username'] . '", "' . $_POST['password'] . ' ); mysql_query($insert_query); } else echo "error somewhere"; ?> Link to comment https://forums.phpfreaks.com/topic/189681-almost-there-but-no-values-are-being-stored-is-it-my-php-or-db-syntax/#findComment-1001097 Share on other sites More sharing options...
jl5501 Posted January 25, 2010 Share Posted January 25, 2010 you seem to have an if with 2 else's Link to comment https://forums.phpfreaks.com/topic/189681-almost-there-but-no-values-are-being-stored-is-it-my-php-or-db-syntax/#findComment-1001168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.