vonKristoff Posted October 4, 2011 Share Posted October 4, 2011 Hi there, Im new here .. I have been trying for hours to just pass a variable from my HTML to a JQuery post which connects to my PHP file, reading the variable sent in the POST, and updating my database. Basically - my PHP is not getting the variable im sending to it - though it is definitely going as my HTML says so. my HTML click function says: $.post("setDB.php",{id:$('#myTxt').val()}); my PHP - connects to its DB with its new MySQLi set to $mysqli - says: $id = $_POST['id']; $query = "INSERT videos SET src = $id"; $result = $mysqli->query($query) or die($mysqli_error($mysqli)); ok - but no way is anything working ...... I have no hair left - if anyone else has some spare - please be my guest Quote Link to comment Share on other sites More sharing options...
gristoi Posted October 5, 2011 Share Posted October 5, 2011 <?php $query = "INSERT INTO videos (`src`) VALUES ('$id')"; Quote Link to comment Share on other sites More sharing options...
cybernet Posted October 7, 2011 Share Posted October 7, 2011 <?php $query = "INSERT INTO videos (`src`) VALUES ('$id')"; your signature fits the reply ) sorry for offtopic but i had to say it Quote Link to comment Share on other sites More sharing options...
Andy-H Posted October 7, 2011 Share Posted October 7, 2011 Your MySQLi INSERT query is formatted as an update query, change it from $id = $_POST['id']; $query = "INSERT videos SET src = $id"; $result = $mysqli->query($query) or die($mysqli_error($mysqli)); to $id = (int)$_POST['id']; $query = "INSERT INTO videos ( $id )"; $result = $mysqli->query($query) or die($mysqli_error($mysqli)); or $id = (int)$_POST['id']; $query = "INSERT INTO videos ( id ) VALUES ( $id )"; $result = $mysqli->query($query) or die($mysqli_error($mysqli)); Quote Link to comment 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.