php - mysql_query not inserting anything into my database -
i have bit of code here:
<?php error_reporting(e_all); include 'db.php'; $con = mysql_connect($host,$user,$pass) or die("error: ".mysql_error()); $dbs = mysql_select_db($databasename, $con); $name = $_post['name']; $date = date('y-m-d'); $amount = $_post['amount']; $timpaid = $_post['timpaid']; $rennypaid = $_post['rennypaid']; $sql = "insert $tablename (`name`, `date`, `amount`, `timpaid`, `rennypaid`) values ('$name', '$date', '$amount', '$timpaid', '$rennypaid')"; $result = mysql_query($con, $sql) or die("error: ".mysql_error()); mysqli_close($con); ?>
db.php database settings. call query on page load , connects , pulls data fine, know it's not issue there. don't errors. status code 200 ok on post.
here's ajax post:
var name = $('#name').val(); var amount = $('#amount').val(); var timpaid = $('#timpaid').val(); var rennypaid = $('#rennypaid').val(); var data = $('#newsubmissionform').serialize(); $.ajax({ url: 'insert.php', data: data, type: 'post', success: function() { window.location.href = ''; } });
does have me serializing it?
i hope enough info. thanks!
mysql_query requires first parameter query , second parameter connection object (optional)
change this
$result = mysql_query($con, $sql);
to
$result = mysql_query($sql, $con);
also used mysql
connection , query used mysqli
close connection.
Comments
Post a Comment