![]() |
| ||
| php wont submit data into the database [php]<? $DBhost = "localhost";//location of mySQL on server/site $DBuser = "michael";//User name for logging onto mySQL $DBpass = "";//Password for logging onto mySQL $DBName = "user_login_info";//Name of the databse for logging into $table = "login_info";//Name of the Table to be used steps to create are included $name = "$_POST[name]";//Name that the person gave on the form $email = "$_POST[email]";//Email that person gave on the form $con_email = "$_POST[confirm_email]";//confirm their email is correct $sex = "$_POST[sex]";//sex of the person $month = "$_POST[month]";//month person was born $day = "$_POST[day]";//day person was born $year = "$_POST[year]";//year person was born if ($email != $con_email) { echo "sorry the emails you provided do not match!<br />"; echo "Please use the back button to correct this error and resubmit<br />"; } else { mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); //connecting to the database using the variable set @mysql_select_db("$DBName") or die("Unable to select database $DBName"); //at connection to the databse select DBNAME (phpforms) or tell that it couldnt connect $sqlquery = "INSERT INTO $table VALUES('$id','$name','$email','$email','$con_email','$sex','$month','$day','$year')"; //Telling the mySQL to insert the values from the form into the databse coresponding with the form $results = mysql_query($sqlquery); //Query the results mysql_close(); echo " <html> <head> <title> Registerd Data </title> </head> <body> <center> <table border='0' width='500'> <tr>"; echo " <td> <font face='verdana' size='+0'> <center> <p>You Just Entered This Information Into the Database</p> </center>"; //display the information that user submitted in the previous form echo " <blockquote> <center> <p> Name : $name </p> <p> E-Mail : $email </p> <p> Sex : $sex </p> <p> Birthdate: $month / $day / $year </p> </center> </blockquote> </td> </tr> </table> </center> </body> </html>"; } ?>[/php] for some reason i cant get this to submit any data into to my database, ive been trying to create a sort of registration form, so i modified the tutorial that i had been working on, but now it wont send the data to my database, but it will display the information that i have entered at the bottom of the screen (the info is displayed in the 'echo' areas. heres the code for the form if you need to see that too <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| ||
| Re: php wont submit data into the database $results = mysql_query($sqlquer y); //Query the results if(!$results){ echo(mysql_error()); } |
| ||
| Re: php wont submit data into the database 1 Attachment(s) Quote:
here are the results. Column count doesn't match value count at row 1 (heres a screenshot of what the database looks like) Quote:
|
| ||
| Re: php wont submit data into the database NP bud. While I am developing I always echo errors after every SQL statement in PHP and keep debug on in other languages. Makes it easier to know off the bat where the problems are. |
| ||
| Re: php wont submit data into the database Quote:
|
| All times are GMT -4. The time now is 12:37 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC