Answer the question
In order to leave comments, you need to log in
$_Post does not accept / return a value. Why?
Hello everyone! For some reason, post either does not accept, or does not correctly give the value. The result is null, although it gives the correct value in alert. There is also some error with the output:
mysql_fetch_row
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in Y:\home\localhost\www\article.php on line 7
<script type="text/javascript" charset="utf-8">
var art_id;
function reply_click(art_id)
{
alert(art_id);
jQuery(document).ready(function(){
jQuery.ajax({
url:"http://localhost/article.php",
type:"POST",
dataType:"json",
data: "art_id" + art_id,
success: function(html){
var ART = jQuery('#ART');
console.log(html);
jQuery.each(html, function(key, value){
console.log(value);
ART.append(value.article_text);
});
}, error: function(e){
alert(e);
}
});
});
}
</script>
<?php
$id = $_POST['art_id'];
print_r(json_encode($id));
$sqlconn = mysqli_connect('localhost','root','','carhelper') or die(mysqli_error());
$query = "SELECT article_text FROM `table_article` where id=$id ";
$res = mysql_query($query);
$row = mysql_fetch_row($res);
print_r(json_encode($row[0]));
?>
Answer the question
In order to leave comments, you need to log in
var art_id; /// it's not clear at all what you could put there when you just declared it
in json, accepted it, then decode json-decode and do not encode json-encode,
otherwise you send json to the selection
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question