sladepowers Posted November 21, 2010 Share Posted November 21, 2010 hope i'm in the right place. Hello,my name is carlton. i have a html form i created in dreamweaver cs. i have the accompanying .php script to forward user details to the server. i fill in the form, hit the submit button and nothing appears in the table i created. the testing server has been successfully configured the database "babiesnmovies" is recognized by dreamweaver. PLS tell me what i'm missing. below is a copy of the form and the script. Thank you so much. //this is the HTML registration web form i created in dreamweaver// <legend>Parents Contact Information</legend> </h3> <form id="form1" name="form1" method="PUT" action="babiesnmovies.php"> <p> <label for="babiesnmovies.com/register">Your First Name</label> <input type="text" name="yourfirstname" id="babiesnmovies.com/register" /> <label for="babiesnmovies.com/registered">Your Last Name</label> <input type="text" name="yourlastname" id="babiesnmovies.com/registered" /> </p> <label for="babiesnmovies.com/yourname">Your Phone Number</label> <input type="text" name="yourphonenumber" id="babiesnmovies.com/yourname" /> <label for="babiesnmovies.com/email">Your E-mail</label> <input type="text" name="youremail" id="babiesnmovies.com/email" /> </p> </form> <p> </p> <h3> <legend>Baby's Vitals</legend> </h3> <form id="form2" name="form2" method="PUT" action="babiesnmovies.php"> <p> <label for="babiesnmovies.com/baby'slast">Baby's First Name</label> <input type="text" name="babysfirstname" id="babiesnmovies.com/baby'sfirst" /> <label for="babiesnmovies.com/babies">Baby's Middle Name</label> <input type="text" name="babysmiddlename" id="babiesnmovies.com/babies" /> </p> <p> <label for="babyslastname">Baby's Last Name</label> <input type="text" name="babyslastname" id="babyslastname" /> </p> <p> <label for="babiesnmovies.com/babybday">Baby's Birthdate</label> <input type="text" name="babysbirthdate" id="babiesnmovies.com/babybday" /> <label for="babiesnmovies.com/babyage">Baby's Age</label> <input type="text" name="babysage" id="babiesnmovies.com/babyage" /> </p> <p> <label for="babiesnmovies.com/baby">Baby's Height</label> <input type="text" name="babysheight" id="babiesnmovies.com/baby" /> <label for="babiesnmovies.com/babyweight">Baby's Weight</label> <input type="text" name="babysweight" id="babiesnmovies.com/babyweight" /> </p> <p> <label for="babiesnmovies.com/babyeyes">Baby's Eye Color</label> <input type="text" name="babyseyecolor" id="babiesnmovies.com/babyeyes" /> <label for="babiesnmovies.com/babyhair">Baby's Hair Color</label> <input type="text" name="babyshaircolor" id="babiesnmovies.com/babyhair" /> </p> <p> <label for="babiesnmovies.com/babyrace">Baby's Ethnicity</label> <input type="text" name="babysethnicity" id="babiesnmovies.com/babyrace" /> </p> <p><input name="formsubmit" type="submit" value="Submit" /> </form> //this is the babiesnmovies.php script// <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_babiesnmovies = "XXX"; $database_babiesnmovies = "XXX"; $username_babiesnmovies = "XXX"; $password_babiesnmovies = "XXX"; $babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db("db337879506", $con); $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL','$yourfirstname', '$yourlastname', '$yourphonenumber', 'youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; $yourfirstname = $_POST ['YourFirstName']; $yourlastname = $_POST ['YourLastName']; $yourphonenumber = $_POST ['YourPhoneNumber']; $youremailaddress = $_POST ['YourE-mailAddress']; $babysfirstname = $_POST ['BabysFirstName']; $babysmiddlename = $_POST ['BabysMiddleName']; $babyslastname = $_POST ['BabysLastName']; $babysbirthdate = $_POST ['BabysBirthdate']; $babysage = $_POST ['BabysAge']; $babysheight = $_POST ['BabysHeight']; $babysweight = $_POST ['BabysWeight']; $babyseyecolor = $_POST ['BabysEyeColor']; $babyshaircolor = $_POST ['BabysHairColor']; $babysethicity = $_POST ['Babys Ethnicity']; ?> Thank you. :'( Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/ Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Your query variable is being set before you set your variables. You also forgot a $ in front of youremailaddress. Once you fix that, post your next error. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137410 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 WOW, what a really fast response time Thank you so much. i made the changes as noted below filled in the form, submitted it but i still receive none of the data in the database panel in dreamweaver. <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_babiesnmovies = "XXX"; $database_babiesnmovies = "XXX"; $username_babiesnmovies = "XXX"; $password_babiesnmovies = "XXX"; $babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db("db337879506", $con); $yourfirstname = $_POST ['YourFirstName']; $yourlastname = $_POST ['YourLastName']; $yourphonenumber = $_POST ['YourPhoneNumber']; $youremailaddress = $_POST ['YourE-mailAddress']; $babysfirstname = $_POST ['BabysFirstName']; $babysmiddlename = $_POST ['BabysMiddleName']; $babyslastname = $_POST ['BabysLastName']; $babysbirthdate = $_POST ['BabysBirthdate']; $babysage = $_POST ['BabysAge']; $babysheight = $_POST ['BabysHeight']; $babysweight = $_POST ['BabysWeight']; $babyseyecolor = $_POST ['BabysEyeColor']; $babyshaircolor = $_POST ['BabysHairColor']; $babysethicity = $_POST ['Babys Ethnicity']; $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL', '$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; ?> Thanks again for the response time...i may finally get somewhere Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137420 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 <form id="form1" name="form1" method="PUT" action="babiesnmovies.php"> Method should be POST Also, I dont see where you actually execute the query that is stored in $sql Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137421 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 hello, made the change to POST from PUT (silly me), then added the last line to the script...still nothing in the dw databases panel in the table "register". pls see below: <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_babiesnmovies = "XXX"; $database_babiesnmovies = "XXX"; $username_babiesnmovies = "XXX"; $password_babiesnmovies = "XXX"; $babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db("db337879506", $con); $yourfirstname = $_POST ['YourFirstName']; $yourlastname = $_POST ['YourLastName']; $yourphonenumber = $_POST ['YourPhoneNumber']; $youremailaddress = $_POST ['YourE-mailAddress']; $babysfirstname = $_POST ['BabysFirstName']; $babysmiddlename = $_POST ['BabysMiddleName']; $babyslastname = $_POST ['BabysLastName']; $babysbirthdate = $_POST ['BabysBirthdate']; $babysage = $_POST ['BabysAge']; $babysheight = $_POST ['BabysHeight']; $babysweight = $_POST ['BabysWeight']; $babyseyecolor = $_POST ['BabysEyeColor']; $babyshaircolor = $_POST ['BabysHairColor']; $babysethicity = $_POST ['Babys Ethnicity']; $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL', '$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; mysql_query($sql, $con) or die (mysql_error()); ?> I can say this much...i am much further ahead than i was this morning and your assistance has been the best. Pls continue to work with me. Thank you. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137426 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 You should be throwing errors, because your database isn't opened. You use $babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); but then use mysql_select_db("db337879506", $con); $con isn't defined so you never open the DB. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137427 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 how do i define or what is the definition for/of $con? i presume $con means "connection". when i hit the submit button i get a blank screen with no error messages. i'm learning. thanks. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137429 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Change $babiesnmovies to $con Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137430 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 like this? $con = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137431 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 it worked!!! this is the exception i got when i hit the submit button: 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 3 i kinda understand but then again i don't. but i am closer. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137433 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Before you run the query, echo $sql and see what it looks like. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137436 Share on other sites More sharing options...
Pikachu2000 Posted November 21, 2010 Share Posted November 21, 2010 Wherever you have spaces between $_POST and the square brackets: $_POST ['YourFirstName'], remove them: $_POST['firstname']. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137479 Share on other sites More sharing options...
sladepowers Posted November 21, 2010 Author Share Posted November 21, 2010 hello all who have helped me on my way. i followed the last set of instructions and the script is now as such: <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_babiesnmovies = "XXX"; $database_babiesnmovies = "XXX"; $username_babiesnmovies = "XXX"; $password_babiesnmovies = "XXX"; $con = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db("db337879506", $con); $yourfirstname = $_POST['YourFirstName']; $yourlastname = $_POST['YourLastName']; $yourphonenumber = $_POST['YourPhoneNumber']; $youremailaddress = $_POST['YourE-mailAddress']; $babysfirstname = $_POST['BabysFirstName']; $babysmiddlename = $_POST['BabysMiddleName']; $babyslastname = $_POST['BabysLastName']; $babysbirthdate = $_POST['BabysBirthdate']; $babysage = $_POST['BabysAge']; $babysheight = $_POST['BabysHeight']; $babysweight = $_POST['BabysWeight']; $babyseyecolor = $_POST['BabysEyeColor']; $babyshaircolor = $_POST['BabysHairColor']; $babysethicity = $_POST['Babys Ethnicity']; $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL', '$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; mysql_query($sql, $con) or die (mysql_error()); ?> i imputed random text in the fields and this is what the exception reads: "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 'dfg')' at line 3" thank you so much revraz and Pikachu2000 Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137669 Share on other sites More sharing options...
BlueSkyIS Posted November 22, 2010 Share Posted November 22, 2010 there is an error in your SQL syntax. take a look to see what your SQL looks like. $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL', '$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; echo "sql: $sql"; Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1137710 Share on other sites More sharing options...
sladepowers Posted November 23, 2010 Author Share Posted November 23, 2010 i would like to thank all those that have helped me to get this far: revraz Picachu2000 BlueSkyIS can anyone tell me specifically how to access this line in sql? "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 3" i'm going through a hosting service and use my-phpadmin. is this where i would locate where the error is? i also access this database via dreamweaver. perhaps i may be able to fix it through there. if there is anyone who can further guide me in how or where to have this issue resolved, pls post. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138324 Share on other sites More sharing options...
revraz Posted November 23, 2010 Share Posted November 23, 2010 You still need to echo $sql so we can see what is being put in your variables. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138344 Share on other sites More sharing options...
sladepowers Posted November 23, 2010 Author Share Posted November 23, 2010 to be honest i dont know how to do that. i am waiting for a copy of php for dummies. so if you could further instruct me i will be grateful and receptive. thank you. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138380 Share on other sites More sharing options...
revraz Posted November 23, 2010 Share Posted November 23, 2010 BlueSky's post has it there. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138387 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2010 Share Posted November 23, 2010 In your form you have the method= attribute specified as 'PUT', however, that isn't a valid method. That's why none of the variables have values. The valid methods are post and get. In this case, since the script that does the processing uses $_POST vars, the proper method for the form is post. You also have 2 separate forms, with one submit button. That isn't going to work, I'm afraid. You should be able to just remove the lines I've commented below to solve that problem. <form id="form1" name="form1" method="PUT" action="babiesnmovies.php"> // <---- CHANGE PUT TO post . . . [sNIP] . . . <input type="text" name="youremail" id="babiesnmovies.com/email" /> </p> </form> // <----- REMOVE THIS <p> </p> <h3> <legend>Baby's Vitals</legend> </h3> <form id="form2" name="form2" method="PUT" action="babiesnmovies.php"> <---- REMOVE THIS <p> <label for="babiesnmovies.com/baby'slast">Baby's First Name</label> You should also enclose the whole php script in a conditional that will stop a database insert from happening if the form hasn't been submitted, and validate and sanitize the data from the form before it goes into the query string, but let's at least get it working first. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138431 Share on other sites More sharing options...
revraz Posted November 24, 2010 Share Posted November 24, 2010 We fixed PUT to POST up at post 4 above. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138787 Share on other sites More sharing options...
sladepowers Posted November 24, 2010 Author Share Posted November 24, 2010 you are making it better revraz. thanks Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138912 Share on other sites More sharing options...
sladepowers Posted November 24, 2010 Author Share Posted November 24, 2010 made the changes...same result. how can i go about getting the sql side of the matter. i use php myadmin via my hosting service so i never really see the action involved. any clues? Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1138916 Share on other sites More sharing options...
Pikachu2000 Posted November 24, 2010 Share Posted November 24, 2010 We kind of need to know exactly what is happening and not happening, along with any errors you may be getting now to be of any further help. Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1139215 Share on other sites More sharing options...
sladepowers Posted November 26, 2010 Author Share Posted November 26, 2010 i think i need to echo the sql. but i don't know how. i've copied other snippets and put my info into them and...this is the most basic of exercises in php. php for dummies didn't make it any clearer for me. but i did remove two of the query: i removed "id" field and the "NULL" from the value it now looks like this: $yourfirstname = $_POST['YourFirstName']; $yourlastname = $_POST['YourLastName']; $yourphonenumber = $_POST['YourPhoneNumber']; $youremailaddress = $_POST['YourE-mailAddress']; $babysfirstname = $_POST['BabysFirstName']; $babysmiddlename = $_POST['BabysMiddleName']; $babyslastname = $_POST['BabysLastName']; $babysbirthdate = $_POST['BabysBirthdate']; $babysage = $_POST['BabysAge']; $babysheight = $_POST['BabysHeight']; $babysweight = $_POST['BabysWeight']; $babyseyecolor = $_POST['BabysEyeColor']; $babyshaircolor = $_POST['BabysHairColor']; $babysethicity = $_POST['Babys Ethnicity']; mysql_select_db("db337879506", $con); $sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName, BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname', '$yourlastname', '$yourphonenumber', $youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')"; mysql_query($sql, $con) or die (mysql_error()); ?> how do i echo this Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1139994 Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 While in development, your queries should be executed in such a manner that if there is an error, it not only echos the error, but also the query string. So to do that, you'd change: mysql_query($sql, $con) or die (mysql_error()); To: mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>'); You should also be developing with display_errors = On, and error_reporting = E_ALL | E_STRICT. You can make those changes in your php.ini file, assuming you're developing and testing on a local machine. If you don't have access to make those changes, you can add the following to your scripts ini_set('display_errors', 1); error_reporting(-1); Link to comment https://forums.phpfreaks.com/topic/219350-i-think-im-kinda-close-but-am-going-in-circles-i-think/#findComment-1140064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.