Hi alll
My first attempt at using mysqli_prepare() is failing and an am stumped as to what I am doing wrong. Here is my query which simply needs to pull out records and display then in a select list:
<?php
$query = "SELECT eventcategoryid, eventcategoryname FROM tbleventcategories WHERE publish = 1 AND siteid = ?";
$stmt = mysqli_prepare($dblink, $query);
mysqli_execute($stmt);
mysqli_stmt_bind_param($stmt, "i", 1);
mysqli_stmt_bind_result($stmt, $eventcategoryid, $eventcategoryname);
while(($res = mysqli_stmt_fetch($stmt))) {
?>
<option value="<?php echo $eventcategoryid; ?>"><?php echo $eventcategoryname; ?></option>
<?php
}
mysqli_stmt_close($stmt);
?>
My understanding is that the mysqli_stmt_bind_param is the function which holds the variables I would normallly write directly int he WHERE clause of a query but I am getting a Fatal Error one htis line: Only variables can be passed by reference.
Can someone help me out and highlight the error in the code?