Folks,
What is wrong with my php mysql query ?
[code]
$total_pages = $conn->query(“SELECT * FROM browsing_histories WHERE username = ?”)->num_rows;
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘?’ at line 1 in C:xampphtdocstestsearch.php:31 Stack trace: #0 C:xampphtdocstestsearch.php(31): mysqli->query(‘SELECT * FROM b…’) #1 {main} thrown in C:xampphtdocstestsearch.php on line 31
If I remove the “WHERE username = ?” part and make it like the following then I get no error.
[code]
$total_pages = $conn->query(“SELECT * FROM browsing_histories WHERE username = ?”)->num_rows;
But making it like this means getting it to pull all rows from the table. I do not want that. I want to pull matching rows in the “username” column.
How to fix this ? How should it have been ?