Hi, I'm new to PHP/mySql and I'm trying pass form data from a html form to my database which I set up on phpmyadmin. The code doesn't give me any errors but the database is just filled with empty rows. Wondering if anyone can point me in the right direction. This is the code: <?php $db = mysql_connect("xxxxx","xxxx","xxxxxx"); if(!$db) die("Error connecting to MySQL database."); mysql_select_db("susie" ,$db); $riskname = $_POST [‘riskname’]; $tradingas = $_POST [‘tradingas’]; $riskaddress = $_POST [‘riskaddress’]; $riskaddress2 = $_POST [‘riskaddress2’]; $riskaddress3 = $_POST [‘riskaddress3’]; $riskaddress4 = $_POST [‘riskaddress4’]; $risktype = $_POST [‘risktype’]; $bsi = $_POST [‘bsi’]; $csi = $_POST [‘csi’]; $stock = $_POST [‘stock’]; $rent = $_POST [‘rent’]; $query = "INSERT INTO Quote (riskname, tradingas, riskaddress, riskaddress2, riskaddress3, riskaddress4, risktype, bsi, csi, stock, rent) VALUES ('$riskname', '$tradingas', '$riskaddress', '$riskaddress2', '$riskaddress3', '$riskaddress4', '$risktype', '$bsi', '$csi', '$stock', '$rent')"; if (!mysql_query($query,$db)) { die('Error: ' . mysql_error()); } echo "Records Added"; mysql_close($db); ?> **when the submit button is clicked 'Records Added' is shown on the screen. But just no information is being passed to database. And this is my form: <div class="contactform"> <form action="susquote.php" method="post"> <fieldset><legend><span style="font-size: 12px;">Proposer Details</span></legend> <label class="left" for="riskname">Proposer Name:</label> <span style="color: #ff0000;">*</span><input id="riskname" class="field" maxlength="35" name="riskname" type="text" tabindex="1" /> <label class="left" for="tradingas">Trading As (if applicable):</label> <span style="color: #ff0000;">*</span><input id="tradingas" class="field" maxlength="35" name="tradingas" type="text" tabindex="2" /><br /><br /> <label class="left" for="riskaddress">Risk Address:</label> <span style="color: #ff0000;">*</span><input id="riskaddress" class="field" maxlength="45" name="riskaddress" type="text" tabindex="3" /><br /> <label class="left" for="riskaddress2"></label><span style="color: #ff0000;"> </span><input id="riskaddress2" class="field" maxlength="35" name="riskadress2" type="text" tabindex="4" /><br /> <label class="left" for="riskaddress3"></label> <span style="color: #ff0000;"> </span><input id="riskaddress3" class="field" maxlength="25" name="riskaddress3" type="text" tabindex="5" /><br /> <label class="left" for="riskaddress4"></label><span style="color: #ff0000;"> </span> <input id="riskaddress4" class="field" maxlength="10" name="riskaddress4" type="text" tabindex="6" /><br /><br /> <label class="left" for="busid">Business Description</label> <span style="color: #ff0000;">*</span> <div class="styled-select"> <select name="risktype"> <option value="pub">Pub</option> <option value="rest">Restaurant</option> <option value="bake">Bakery</option> </select></div> </fieldset> <fieldset><legend><span style="font-size: 12px;">Sums Insured</span></legend> <br /> <label class="left" for="bsi">Building Sums Insured:</label> <span style="color: #ff0000;">*</span><input id="bsi" class="field" maxlength="35" name="bsi" type="text" tabindex="14" /><br /><br /> <label class="left" for="csi">Contents Sums Insured:</label> <span style="color: #ff0000;">*</span><input id="csi" class="field" maxlength="35" name="csi" type="text" tabindex="15" /><br /><br /> <label class="left" for="stock">Stock in Trade:</label> <span style="color: #ff0000;">*</span><input id="stock" class="field" maxlength="35" name="stock" type="text" tabindex="16" /><br /><br /> <label class="left" for="rent">Loss of Rent:</label> <span style="color: #ff0000;">*</span><input id="rent" class="field" maxlength="35" name="rent" type="text" tabindex="17" /><br /><br /> </fieldset> </form> </span> </div> Thanks for any and all help
When I do echo $query I get this. So the values are being passes properly. But I can't see why or where I went wrong. Records AddedINSERT INTO Quote (riskname, tradingas, riskaddress, riskaddress2, riskaddress3, riskaddress4, risktype, bsi, csi, stock, rent) VALUES ('','', '', '', '', '', '', '', '', '', '')
Problem solved - changing $riskname = $_POST [‘riskname’]; to $riskname = $_POST["riskname"]; seems to have done the trick.