I'm using prepared statements and MySQLi, and am currently getting this error.
PHP Catchable fatal error: Object of class mysqli_stmt could not be converted to string in /Users/me/path/to/project/ModelBase/City.php on line 31
The code it's coming from (full function):
function select($query, $limit)
{
$query = "%".$query."%";
$con = ModelBase::getConnection();
$sql = "SELECT name FROM cities WHERE name LIKE ? LIMIT ?";
$query = $con->prepare($sql) or die("Error preparing sql in City ".parent::$db_conn->error);
$query->bind_param("si", $query, $limit) or die("Error binding params in City ".parent::$db_conn->error);
$query->execute() or die("Error executing query in City");
$tmp = "";
$res = $query->bind_result($tmp);
while($query->fetch());
{
$citylist[] = $tmp;
}
$query->close();
}
Like 31 is the $query->execute(). I can't find any information about this, and this is almost identical syntax to other systems I've built and never had this issue.