I have an issue with a table in a database. There are three columns as follows:
Name (VARCHAR(25))
QText (TEXT)
AText (TEXT)
My query is run through PDO as:
SELECT `AText` FROM `Exam_QA_Data` WHERE `Name` = '$name' AND `QText` = '$question'
After processing it looks like this and obviously the length of the $question
variable will change:
SELECT `AText` FROM `Exam_QA_Data` WHERE `Name` = 'ExamServerTestExam' AND `QText` = 'This is the first question'
From what I can see depending on the length of the string in place of $question
, sometimes it will return a row, other times it returns nothing.
If the string is short (27 chars) then it returns the 'AText'
content for that row, though if the string is long (106 chars) nothing if $question
is a long string. I checked the entry in the database and the entire string is present, so the row is there exactly as it is being searched for.
I have also tried using:
SELECT `AText` FROM `Exam_QA_Data` WHERE `Name` = '$name' AND `QText` LIKE '%$question%'
Can't understand if this is a database issue or not and if so why? It appears to be a problem with the length of the input string.
Thank you very much.