|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Script won't insert data to table
I submit the form to insert the data into the table, when I submit the form for this script to process, The "if" statement is true because the "echo" statement in the else says so, but the else is what the script is doing. Can't figure out why.
What am I missing here? <html><body> <?php include ("dbconnect_test.php"); if ($submit == "Submitted") { echo ("Submit ='Submitted'"); $query = "insert into tbl_members (name,chapter,position,category,business_name,addr ess1,address2,city,state,zip,phone,fax,e-mail,web_address) values ('$name','$chapter','$position','$category','$busi ness_name','$address1','$address2','$city','$state ','$zip','$phone','$fax','$e-mail','$web_address')" ; mssql_query($query) or die ("unable to Insert Data"); ?> <h2>Thanks!!</h2> <h2><a href="view.php"> View The List </a></h2> <?php } else { echo ("Submit ='Submitted'"); echo "Doing the else"; include("members_test.php"); } ?> </body></html> |
|
#2
|
|||
|
|||
|
RE: Script won't insert data to table
As a followup I've corrected the spelling for the mysql query statement, and streamlined the code partly by removing all the column specs as that is interpreted to insert all columns. I'm still getting the "unable to Insert Data". I'm also using the echo statements to make sure the variables are correct but the script is not inserting them.
<?php include ("dbconnect_test.php"); echo "<BR>"; echo "Receives ($name)"; echo "Receives ($chapter)"; echo "<BR>"; mysql_query ("INSERT INTO tbl_members",$db) or die ("unable to Insert Data"); ?> |
|
#3
|
|||||
|
|||||
|
RE: Script won't insert data to table
You can take out the field names like you said but you still need the VALUES. Like this:
php Code:
HTH |
|
#4
|
||||
|
||||
|
RE: Script won't insert data to table
I'm not sure I am following you because it appears you are saying the echo statement in the else is being displayed. If this is the case then your problem is the submit value. Beyond that it's not clear because of the include if you have actually made the connection to the database. Do an !isset check on the db connection. perhaps you should just echo $submit; in both places so you can see what it is as opposed to echoing a line of text. You could also run a foreach to see exactly what you are passing to the page. Lastly you could try and put all the field names in backticks ` this sometimes helps.
B |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Script won't insert data to table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|