I have a form where a user can do a search. If the user types in '\' (slash character), I get the following error below. What is the problem here?
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /var/ on line 23
The full SQL related to this error is:
SELECT Users.`Index`, Users.ProfileName, Users.PrimaryEmail, Users.FirstName, Users.LastName FROM Users WHERE Users.ProfileName LIKE '%\%' OR Users.FirstName LIKE '\%' OR Users.LastName LIKE '\%' OR Users.PrimaryEmail = '\' ORDER BY Users.ProfileName, Users.LastName, Users.FirstName, Users.PrimaryEmail LIMIT 10;
Alternatively, I have a different search form where I can search for '\' and not get an error. This non-erroring SQL is below. Why does this SQL statement not error?
SELECT Movies.`Index`, Movies.Title FROM Movies WHERE Movies.Title LIKE '\%' UNION SELECT Movies.`Index`, Movies.Title FROM Movies WHERE Movies.Title LIKE '% \%' LIMIT 10;
How does someone normally handle this when building an SQL statement?
Nick
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /var/ on line 23
The full SQL related to this error is:
SELECT Users.`Index`, Users.ProfileName, Users.PrimaryEmail, Users.FirstName, Users.LastName FROM Users WHERE Users.ProfileName LIKE '%\%' OR Users.FirstName LIKE '\%' OR Users.LastName LIKE '\%' OR Users.PrimaryEmail = '\' ORDER BY Users.ProfileName, Users.LastName, Users.FirstName, Users.PrimaryEmail LIMIT 10;
Alternatively, I have a different search form where I can search for '\' and not get an error. This non-erroring SQL is below. Why does this SQL statement not error?
SELECT Movies.`Index`, Movies.Title FROM Movies WHERE Movies.Title LIKE '\%' UNION SELECT Movies.`Index`, Movies.Title FROM Movies WHERE Movies.Title LIKE '% \%' LIMIT 10;
How does someone normally handle this when building an SQL statement?
Nick