aHMAD_SQaLli Posted October 21, 2015 Share Posted October 21, 2015 Hello every one $db_mysqli_connect = mysqli_connect("localhost", "root", "root", "PSE_database"); if (mysqli_connect_errno($db_mysqli_connect)) { echo 'Some error occurred during connection to the database';} $LIKE = "rammstein"; if ($stmt = mysqli_prepare($db_mysqli_connect, "SELECT document_title FROM pse_docs WHERE document_title LIKE ?")) { mysqli_stmt_bind_param($stmt, "s", $LIKE); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if(mysqli_num_rows($result) !== 0) { while ($row = mysqli_fetch_assoc($result)){ echo $row['document_title']. "<br>"; } } else { echo "Not Found"; } } else { trigger_error('Unable query users table: ' . mysqli_error($db_mysqli_connect)); } mysqli_free_result($result); mysqli_stmt_close($stmt); mysqli_close($db_mysqli_connect); this code does not work, it returns nothing, btw, document title is Rammstein ! Thanks. Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted October 21, 2015 Solution Share Posted October 21, 2015 You use LIKE with wildcards when you are searching for something that contains the search string. If you are looking for an exact match use "=". In this case it could be that perhaps the title in the db has extra space character at the end. Try this with your current query $LIKE ="%rammstein%"; If that fails it could be you are using a case-sensitive collation. Quote Link to comment Share on other sites More sharing options...
aHMAD_SQaLli Posted October 21, 2015 Author Share Posted October 21, 2015 Thank you sir. it worked ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.