ncorrieri Posted February 20, 2007 Share Posted February 20, 2007 hey all - im trying to go back and repair some old code, and i dont know what im doing This should be able to connect to database fine, however, it is not inserting. Posting data to this page. What do you think is wrong with this page? ------------- <? require_once("config.php"); $data = $_POST; $data['dob'] = "$data[dobYYYY]-$data[dobMM]-$data[dobDD]"; $t = "registration"; $q = "INSERT INTO $t (`id`,`prefix`,`suffix`,`fname`,`lname`,`gender`,`dob`, `address1`,`address2`,`city`,`state`,`email`,`areacode`, `regtime`,`ipaddress`,`offer`,`affiliate`,`subaffiliate`) VALUE ( null,[prefix],[suffix],[fname],[lname],[gender],[dob], [address1],[address2],[city],[state],[email], [areacode],NOW(),[ipaddress],[offer],[affiliate],[subaffiliate])"; foreach ($data as $key => $value) { $value = "'".mysql_real_escape_string($value)."'"; $q = str_replace("[$key]",$value,$q ); } mysql_query($q); ?> Quote Link to comment https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/ Share on other sites More sharing options...
Balmung-San Posted February 20, 2007 Share Posted February 20, 2007 Replace mysql_query($q) with mysql_query($q) or die (mysql_error()); That will give us a better description of what's wrong. Quote Link to comment https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/#findComment-189738 Share on other sites More sharing options...
ncorrieri Posted February 20, 2007 Author Share Posted February 20, 2007 did that, got this error. You have an error in your SQL syntax near 'VALUE ( null,'298','3920','James','McDoodle','M','1980-12-1', '101 1st Street' at line 4 following value would have been address2 but it was blank Quote Link to comment https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/#findComment-189770 Share on other sites More sharing options...
Balmung-San Posted February 20, 2007 Share Posted February 20, 2007 *hits head* Change: VALUE To: VALUES Quote Link to comment https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/#findComment-189772 Share on other sites More sharing options...
ncorrieri Posted February 20, 2007 Author Share Posted February 20, 2007 that worked! thanks! now i just need to figure out whats wrong with this reporting page (ill make another thread hehe) Quote Link to comment https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/#findComment-189827 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.