Going on 2nd Day...

Discussion in 'Databases' started by Sleeping Troll, Sep 17, 2008.

  1. #1
    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):
     
    Sleeping Troll, Sep 17, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    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]'";
     
    mwasif, Sep 17, 2008 IP