I have a database which contains authors and books. Some of those authors and books contain slashes in the name or title fields. When I query the database for authors, it matches just fine, with or without slashes. When I query books, however, it only finds books without slashes in the title.
Here is the code I use for converting values to allow the user to choose one author or book:
AUTHORS:
$result = mysqli_query($con,"SELECT * FROM authors");
while($row = mysqli_fetch_assoc($result))
{
$string=iconv ( "Windows-1252" , "UTF-8" , $row[name] );
echo '<option value = "';
echo $string;
echo '">';
echo $string;
echo '</option>';
}
BOOKS:
$result = mysqli_query($con,"SELECT * FROM books order by bookTitle");
while($row = mysqli_fetch_assoc($result))
{
$string=iconv ( "Windows-1252" , "UTF-8" , $row[bookTitle] );
echo '<option value = "';
echo $string;
echo '">';
echo $string;
echo '</option>';
}
Here is the code I use for populating the form from the chosen book or author:
AUTHOR
$result = (mysqli_query($con,"SELECT * FROM authors WHERE name = '$_POST[authorName]'"));
BOOK
$result = (mysqli_query($con,"SELECT * FROM books WHERE bookTitle = '$_POST[bookName]'"));
The AUTHOR will return values associated with the author chosen by the user. The BOOK will not return values for the chosen book if there is a slash in the title. It says there are no matching records.
What am I missing?