
March 5th, 2006, 08:28 AM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 22,309
Time spent in forums: < 1 sec
Reputation Power: 24
|
|
|
DB Syntax Error on update query that runs successful in Query Analyzer
I am currently working on a site which uses Pear DB with PHP and MSSQL (SQL Server 2000). I have found an update query that is returning "DB Error: syntax error" when run from within the php application. What has me bogged down is, if I echo out this same query and run it in the SQL Server Query Analyzer - the query is successful.
Any ideas on why the validation results are different?
Not sure if this will help, but the code that I am debugging is as follows:
php Code:
Original
- php Code |
|
|
|
switch( $sQueryType ) { case 'update': foreach( $this->_aTableFields as $sTableName => $aTableFields ) { if( 0 < count( $aTableFields )) { foreach( $aTableFields as $sFieldName ) { $sTmp = ''; $sTmp .= $sFieldName . ' = '; $sTmp .= ''' . $this->_aUserInfo[$sFieldName] . '''; $aQueryParts[] = $sTmp; } } if( 0 < count( $aQueryParts )) { $sUpdateQuery = 'UPDATE ' . $sTableName . ' SET ' . ' WHERE ' . $this->_sUIDField . ' = '' . $sUID . '''; if( '' == $sQueryError ) { $sUpdateQueryResult =& $this->_oDBConn->query($sUpdateQuery); if(( !$sUpdateQueryResult ) || ( DB::isError($sUpdateQueryResult))) { $sQueryError = $sUpdateQueryResult->getMessage(); } } } } } break;
Any advice would be greatly appreciated.
Thanks
JS
|