Re: Problem with passing variable to mssql

From: Date: Thu, 28 Jun 2007 13:30:17 +0000
Subject: Re: Problem with passing variable to mssql
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-43728@lists.php.net to get a copy of this message
William Curry wrote:
I have issues I cant understand passing a sql statement to mssql, most of which work fine, however in some cases, a statement like "SELECT * FROM tblX where value like 'variable%' " will return 0 records when I know they are there. No errors, just 0 records. When I echo the sql string to the page, cut and paste it into SQL query analyzer, the exact same statement returns the expected records. Anyome point me to the answer??
It's over there -----> Sorry, couldn't resist. Anyhoo, are you expecting variable to be replaced with the contents of $variable? If so that's never going to work. Try this instead... "SELECT * FROM tblX where value like '".str_replace("'", "''", $variable)."%' " -Stut -- http://stut.net/

« previous php.db (#43728) next »