This is the code: $SQL="Select * From ProjectText Where ProjectID = $ProjectID"; $Texts= mysql_query($SQL); while($Txt = mysql_fetch_array($Texts)); { $SQL="Select * From Texts Where TemplateID = $TemplateID and TextID = $Txt[1]"; $result = mysql_query($SQL); $row = mysql_fetch_row($result); $PosLeft = $row[2]*$Inch; $PosBottom = $row[3]*$Inch; $PosWidth = $row[4]*$Inch; $PosHeight = $row[5]*$Inch; $Font = "Fonts/$row[6]"; $Color = $row[7]; $Shadow = $row[8]; //Create Cropped Overlay Image imagettftext($overlay , 36 , 0 , $PosLeft , $PosBottom, $red , $Font , $Txt[2]); } Code (markup): This is the data: ProjectID, TextID, Text 127, 2, is a Test 127, 1, This ProjectID = VARCHAR TextID = VARCHAR Text =VARCHAR Code (markup): Why does $Txt[1] evaluate to "null"? echoed SQL: Select * From Texts Where TemplateID = $TemplateID. and TextID = Code (markup):
Use single quotes around varchar values. e.g. $SQL="Select * From ProjectText Where ProjectID = '$ProjectID'"; $SQL="Select * From Texts Where TemplateID = '$TemplateID' and TextID = '$Txt[1]'";