jabbamonkey Posted October 22, 2003 Share Posted October 22, 2003 I have a form that is trying to upload the information into the MySQL satabase. BUT, for some reason the new rows aren\'t being added, and I am not getting any error message. I have similar forms that enter information into other tables just fine, but this one is not working... Can someone tell me the best way to trouble shoot this? As the information isn\'t actually getting submitted in the table, is there some way I can have an error message appear telling me what\'s wrong? Here is the code below.... $db = mysql_connect($host, $user, $pass); mysql_select_db($dbname,$db); $sql = mysql_query(" INSERT INTO survey_readerstudy (howold, havepark, fampark, email_address) VALUES (\'$howold\', \'$havepark\', \'$fampark\', \'$email_address\')",$db); Please help!!! Quote Link to comment https://forums.phpfreaks.com/topic/1212-form-mysql-database/ Share on other sites More sharing options...
sir nitr0z Posted October 22, 2003 Share Posted October 22, 2003 you say similiar forms, are you using action=\"PHP_SELF\"? might need to $data = $_POST[\'data\']; for all ur variables Quote Link to comment https://forums.phpfreaks.com/topic/1212-form-mysql-database/#findComment-4051 Share on other sites More sharing options...
jabbamonkey Posted October 22, 2003 Author Share Posted October 22, 2003 I have the action going to the confirm page (every form I have, has it\'s own confirm page) action=\"survey_confirm.php\" Not sure what you mean by: $data = $_POST[\'data\']; Where would this go, and what would this do? Jabbamonkey Quote Link to comment https://forums.phpfreaks.com/topic/1212-form-mysql-database/#findComment-4053 Share on other sites More sharing options...
cjkent17 Posted October 29, 2003 Share Posted October 29, 2003 the $data = $_POST[\'data\']; that that guy is referring to means that the you might not have register_globals turned on in his/her php.ini file. If you don\'t have it on, it would tell you that it couldn\'t find the variable that you are referring to., if it doesn\'t do this, don\'t worry about it, if it does, then you need to either turn register globals on (if you can) or make sure every variable you are trying to turn on is initialized first, as in: [php:1:135977b415]<?php $howold=$_POST[\'howold\']; $havepark=$_POST[\'havepark\']; ?>[/php:1:135977b415] etc. as for the original problem, try and change your code to: [php:1:135977b415]<?php $db = mysql_connect($host, $user, $pass); mysql_select_db($dbname,$db); $inserted = mysql_query(\"INSERT INTO `survey_readerstudy` (`howold`,`havepark`,`fampark`,`email_address`) VALUES (\'$howold\', \'$havepark\', \'$fampark\', \'$email_address\')\",$db) or die (mysql_error()); ?>[/php:1:135977b415] that way if any error results in stopping the db from inserting the record, it will stop the page right then and there and output the error message. if you want your page to continue only if it inserts, do this: [php:1:135977b415]<?php if ($inserted) { // this is the query variable of your insert into query // insert your successful code } elseif (!$inserted) { // output your error message here } ?>[/php:1:135977b415] hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/1212-form-mysql-database/#findComment-4141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.