So had this code for course catalog search field:
if (isset($_POST['submit']))
$search = $_POST['search'];
$byNameOrCode = mysqli_query($link, "SELECT course_name, course_code, ects_credits FROM courses WHERE course_name LIKE '%$search%' OR course_code LIKE '%$search%'");
it worked perfectly but had to change to parameter binding. so I switched last line with:
$byNameOrCode = mysqli_stmt_prepare($link, "SELECT course_name, course_code, ects_credits FROM courses WHERE course_name LIKE ? OR course_code LIKE ?");
mysqli_stmt_bind_param($byNameOrCode, "ss", "%" . $search . "%", "%" . $search . "%");
mysqli_stmt_execute($byNameOrCode);
mysqli_stmt_bind_result($byNameOrCode, $course_code, $course_name, $ects_credits, $semester_name);
It crashed the whole page. Then I did:
if (isset($_POST['submit']))
$search = '%' . $_POST['search'] . '%';
mysqli_stmt_bind_param($byNameOrCode, "ss", $search, $search);
mysqli_stmt_execute($byNameOrCode);
mysqli_stmt_bind_result($byNameOrCode, $course_code, $course_name, $ects_credits, $semester_name);
the page is okay but it does not seem to search anything. anyone has any idea how to fix it?