PHP Mysql Insert Into not working, no error given no data posted to DB -


trying setup warranty registration page friends company , i'm not great @ mysql or php (read: noob). i've scoured web answers , have tried several variations code below no success.

i have table setup matching column names. form submission setup correctly believe.

just not stopping posting data database. appreciated.

here's post code.

<?php error_reporting(-1);   $firstname = $_post['firstname']; $lastname = $_post['lastname']; $address = $_post['address']; $city = $_post['city']; $state = $_post['state']; $zipcode = $_post['zipcode']; $country = $_post['country']; $phone = $_post['phone']; $email = $_post['email']; $ordernumber = $_post['ordernumber']; $receivedate = $_post['receivedate']; $placeofpurchase = $_post['placeofpurchase']; $newsletter = $_post['newsletter']; ?>  <?php $con = mysqli_connect("localhost","db_username","password","db_name"); if (mysqli_connect_errno())   {   echo "failed connect mysql: " . mysqli_connect_error();   }  $sql = ("insert warrantyregistration (firstname, lastname, address, city, state, zipcode, country, phone, email, ordernumber, receivedate, placeofpurchase, newsletter) values ($firstname, $lastname, $address, $city, $state, $zipcode, $country, $phone, $email, $ordernumber, $receivedate, $placeofpurchase, $newsletter)");   if (mysqli_query($con,$sql))   {   die('error: ' . mysqli_error($con));   } echo "success!";  mysqli_close($con) ?> 

change line:

if (mysqli_query($con,$sql)) 

to:

if (!mysqli_query($con,$sql)) 

and should see error message.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -