From: [EMAIL PROTECTED]
Operating system: SCO Openserver 5.0.5 & RH Lnux 7
PHP version: 4.0.6
PHP Bug Type: ODBC related
Bug description: Openlink 3.2 and 4.0 odbc_do and single quotes
Came across this issue when doing my data conversions. If the fields have
single quotes in them, odbc_do fails.
I have tested this against the Openlink 3.2 and 4.1 SDK's and found that
using odbc_prepare works fine.
Basic Script
------------
<?
$conn = odbc_connect("$dsn","","","$cursor");
$sql="SELECT ID,Category,description FROM card_type WHERE
description='IMPEYS'";
echo "<BR><b>SQL:</b> $sql<BR>";
$results = odbc_do($conn,$sql);
if ($results) {
while (odbc_fetch_into($results,$row)) {
echo $row[0]." ".$row[1]." ".$row[2]."\n";
}
}
$sql="SELECT ID,Category,description FROM card_type WHERE description LIKE
'%PEP%'";
echo "<BR><b>SQL:</b> $sql<BR>";
$results = odbc_do($conn,$sql);
if ($results) {
while (odbc_fetch_into($results,$row)) {
echo $row[0]." ".$row[1]." ".$row[2]."\n";
}
}
$sql='SELECT ID,Category,description FROM card_type WHERE description LIKE
"%PEP%"';
echo "<BR><b>SQL:</b> $sql<BR>";
$results = odbc_do($conn,$sql);
if ($results) {
while (odbc_fetch_into($results,$row)) {
echo $row[0]." ".$row[1]." ".$row[2]."\n";
}
}
$sql='SELECT ID,Category,description FROM card_type WHERE
description="PEPPERELL\'S"';
echo "<BR><b>SQL:</b> $sql<BR>";
$results = odbc_do($conn,$sql);
if ($results) {
while (odbc_fetch_into($results,$row)) {
echo $row[0]." ".$row[1]." ".$row[2]."\n";
}
}
$sql="SELECT ID,Category,description FROM card_type WHERE
description=\"PEPPERELL'S\"";
echo "<BR><b>SQL:</b> $sql<BR>";
$results = odbc_do($conn,$sql);
if ($results) {
while (odbc_fetch_into($results,$row)) {
echo $row[0]." ".$row[1]." ".$row[2]."\n";
}
}
/*
Output
------
SQL: SELECT ID,Category,description FROM card_type WHERE
description='IMPEYS'
355 Other Item IMPEYS
SQL: SELECT ID,Category,description FROM card_type WHERE description LIKE
'%PEP%'
177 Other Item PEPPERELL'S
SQL: SELECT ID,Category,description FROM card_type WHERE description LIKE
"%PEP%"
Warning: SQL error: [OpenLink][ODBC][Driver]Syntax error or access, SQL
state 37000 in SQLExecDirect in /usr/local/.WWW/WEBS/_odbc/test.php3 on
line 42
SQL: SELECT ID,Category,description FROM card_type WHERE
description="PEPPERELL'S"
Warning: SQL error: [OpenLink][ODBC][Driver]Syntax error or access, SQL
state 37000 in SQLExecDirect in /usr/local/.WWW/WEBS/_odbc/test.php3 on
line 50
SQL: SELECT ID,Category,description FROM card_type WHERE
description="PEPPERELL'S"
Warning: SQL error: [OpenLink][ODBC][Driver]Syntax error or access, SQL
state 37000 in SQLExecDirect in /usr/local/.WWW/WEBS/_odbc/test.php3 on
line 58
*/
?>
--
Edit bug report at: http://bugs.php.net/?id=13809&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]