will_1990 Posted March 4, 2009 Share Posted March 4, 2009 Despite being able to get the query to work sucessfully in phpmyadmin with static data, when i swap this out for my variable input this does not work. this works in phpmyadmin and returns the expected data on the webpage. $sql = 'SELECT bt.BtId, bt.BtName, BookCopy.BcId, PubName, AuthorId, AuthorName' . ' FROM BookTitle AS bt' . ' CROSS JOIN BookCopy USING (BtId)' . ' CROSS JOIN Loan USING (BcId)' . ' CROSS JOIN Publisher USING (PubId)' . ' CROSS JOIN Authorship USING (BtId)' . ' CROSS JOIN Author USING (AuthorId)' . ' WHERE' . ' Loan.DateBack IS NOT NULL' . ' AND' . ' bt.BtName LIKE \'%Harry%\' AND Author.AuthorName LIKE \'%row%\' LIMIT 0, 30 '; However when it is edited to: . ' bt.BtName LIKE \'%$bn%\' AND Author.AuthorName LIKE \'%$an%\' LIMIT 0, 30 '; [/code] the expected output is completely blank. Why is this is there a way to solve this or a work around? Many thanks Quote Link to comment Share on other sites More sharing options...
corbin Posted March 5, 2009 Share Posted March 5, 2009 Variables are not parsed inside of ''. You need to use "" if you want variables parsed inside of quotes. Quote Link to comment Share on other sites More sharing options...
will_1990 Posted March 5, 2009 Author Share Posted March 5, 2009 Variables are not parsed inside of ''. You need to use "" if you want variables parsed inside of quotes. Is this how its meant to be? . ' bt.BtName LIKE \'%"$bn"%\' AND Author.AuthorName LIKE \'%"$an"%\' LIMIT 0, 30 '; Quote Link to comment Share on other sites More sharing options...
samshel Posted March 5, 2009 Share Posted March 5, 2009 . ' bt.BtName LIKE \'%'.$bn.'%\' AND Author.AuthorName LIKE \'%'.$an.'%\' LIMIT 0, 30 ' this shud work !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.