samf_20 Posted November 28, 2008 Share Posted November 28, 2008 Hi, I have created a online ordering form which works perfectly. But when I wrote my mysql statement to get it to be inserted into my database nothing displays in the database. Here is the code I got: mysql_select_db("mcerts", $con); $insertQuery = "Insert into conferencereg(fullname, companyname, positiontitle, streetaddress, city, countystate, zipcode, countryname, telephone, fax, email, isregisterforfive, isattendinggaladinner"; $insertValues = "values('$_POST[fullname]','$_POST[company]','$_POST[positiontitle]','$_POST[street]','$_POST[city]','$_POST[county]','$_POST[postcode]','$_POST[country]','$_POST[telephone]','$_POST[fax]','$_POST[email]',"; if(isset($_POST["registrationday"])) { // if (strcmp ($_POST["registrationday"],"55.001")>0){ if ($_POST["registrationday"]=="55.001"){ $insertValues = $insertValues."1"; } else if ($_POST["registrationday"]=="55.002"){ $insertValues = $insertValues."2"; } else if ($_POST["registrationday"]=='100.00'){ $insertValues = $insertValues."3"; } } if(isset($_POST["fifthDecCheckBox"])) { $insertValues = $insertValues.",1"; } else { $insertValues = $insertValues.",0"; } if(isset($_POST["card"])) { $insertQuery = $insertQuery.", iscardpaymentmode, cardtype, cardnumber, cvv2number, cardholdername, cardexpirydate, dinnerstreet, dinnercity, dinnercountystate, dinnerpostalcode, dinnercountry"; $insertValues = $insertValues. ",1,'$_POST[cardtype]','$_POST[cardnumber]','$_POST[cvv2number]','$_POST[cardholdername]','$_POST[cardexpirydate]','$_POST[cardstreet]','$_POST[cardcity]','$_POST[cardcounty]','$_POST[cardpostcode]','$_POST[cardcountry]'"; } else if(isset($_POST["invoice"])) { $insertQuery = $insertQuery.", isinvoicepaymentmode, dinnerstreet, dinnercity, dinnercountystate, dinnerpostalcode, dinnercountry"; $insertValues = $insertValues. ",1,'$_POST[invoicestreet]','$_POST[invoicecity]','$_POST[invoicecounty]','$_POST[invoicepostcode]','$_POST[invoicecountry]'"; } else if(isset($_POST["cheque"])) { $insertQuery = $insertQuery.", ischequepaymentmode"; $insertValues = $insertValues. ",1"; } else { $insertValues = $insertValues.",0"; } //echo $insertQuery.") ".$insertValues.")"; $strQuery=$insertQuery.") ".$insertValues.")"; //echo ($strQuery); mysql_query($strQuery); // ?> Any help will be appreciated! Thanks, Sam Quote Link to comment https://forums.phpfreaks.com/topic/134649-cannot-get-insert-into-working/ Share on other sites More sharing options...
rhodesa Posted November 28, 2008 Share Posted November 28, 2008 what is the final output of echo ($strQuery); Quote Link to comment https://forums.phpfreaks.com/topic/134649-cannot-get-insert-into-working/#findComment-701069 Share on other sites More sharing options...
samf_20 Posted November 28, 2008 Author Share Posted November 28, 2008 Insert into conferencereg(fullname, companyname, positiontitle, streetaddress, city, countystate, zipcode, countryname, telephone, fax, email, isregisterforfive, isattendinggaladinner, isinvoicepaymentmode, dinnerstreet, dinnercity, dinnercountystate, dinnerpostalcode, dinnercountry) values('sam','sam','sam','sam','sam','sam','sam','UNITED KINGDOM','21123','213213','email address',1,0,1,'sam','sam','sam','sam','UNITED KINGDOM') Quote Link to comment https://forums.phpfreaks.com/topic/134649-cannot-get-insert-into-working/#findComment-701118 Share on other sites More sharing options...
revraz Posted November 28, 2008 Share Posted November 28, 2008 mysql_query($strQuery) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/134649-cannot-get-insert-into-working/#findComment-701125 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.