I can upload to server “Fatal error: Uncaught Error: Call to undefined function fetch_assoc()” etc [duplicate]

让人想犯罪 __ 提交于 2020-01-11 14:48:09

问题


I am currently making a comment section with two tables. One is the main comment section, I can comment and it uploads to the server. The replies also upload to the server, however they do no display on the website and it returns this error witht he line of code affected, this is the php code...

if (isset($_POST['addComment'])) {
  $comment = $conn->real_escape_string($_POST['comment']);
  $isReply = $conn->real_escape_string($_POST['isReply']);
  $commentID = $conn->real_escape_string($_POST['commentID']);

  if ($isReply) {
      $conn->query("INSERT INTO replies (replyMessage, commentID, userID, createdOn) VALUES ('$comment', '$commentID', '$user_id', NOW())");
      $sqlGetComment = $conn->query("SELECT replies.repliesID, uidUsers, message, DATE_FORMAT(replies.createdOn, '%Y-%m-%d') AS createdOn FROM replies 
      INNER JOIN users ON replies.userID = users.idUsers ORDER BY replies.repliesID DESC LIMIT 1");
  } else {
      $conn->query("INSERT INTO user_comment_table (user_id, message, created_on) VALUES ('$user_id', '$comment', NOW())");
      $sqlGetComment = $conn->query("SELECT user_comment_table.comment_id, uidUsers, message, DATE_FORMAT(user_comment_table.created_on, '%Y-%m-%d') AS created_on FROM user_comment_table 
      INNER JOIN users ON user_comment_table.user_id = users.idUsers ORDER BY user_comment_table.comment_id DESC LIMIT 1");
  }

  $data = fetch_assoc($sqlGetComment);
    exit(createCommentRow($data));

}

any ideas on what to do guys? If anyone could lend a hand it would be much appreciated.

来源:https://stackoverflow.com/questions/59548786/i-can-upload-to-server-fatal-error-uncaught-error-call-to-undefined-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!