Skip to content

Instantly share code, notes, and snippets.

@Crakila
Last active December 20, 2015 07:38
Show Gist options
  • Save Crakila/6094396 to your computer and use it in GitHub Desktop.
Save Crakila/6094396 to your computer and use it in GitHub Desktop.
I am getting a error when I run this. It's saying "Fatal Error: Call to undefined method mysqli_result::bind_params() in <file location> on line 18". It's complaining about the $query->bind_params line. Any help would be appreciated. Thanks! EDIT: Fixed. On Line 17, I had "if($query = $db->query($sql)){" instead of "if($query = $db->prepare($sql…
<?php
session_start();
require"db_cnt.php";
$sql = "SELECT forum_id, forum_name FROM forum_tabl";
if(isset($_GET['id'])&&is_numeric($_GET['id'])){
$id = $_GET['id'];
}else{
die("ERROR!");
}
//check if forum has valid id
$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = '$id'");
if($idCheck->num_rows !==1){
die("No forum under that id was found!");
}
$row = $idCheck->fetch_object();
$sql = "SELECT post_id, post_title FROM forum_post WHERE forum_id=1 AND post_type='o' ";
if($query = $db->prepare($sql)){
$query->bind_params('s', $id);
$query->bind_result($post_id, $post_title);
$query->execute();
$query->store_result();
}else{
echo $db->error;
}
?>
@Crakila
Copy link
Author

Crakila commented Jul 27, 2013

Updated to show whole php file.

@Crakila
Copy link
Author

Crakila commented Jul 28, 2013

Updated to show fix. Check revisions for changes to the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment