Menu

#311 [PHP] The string handled by method cubrid_real_escape_string can not be inserted into table

open
nobody
None
5
2012-10-10
2012-10-10
Jira Trac
No

The string handled by method cubrid_real_escape_string can not be inserted into table

Test verion:
{noformat}
Cubrid: CUBRID 9.0 (9.0.0.0455)
PHP Driver:
http://svn.cubrid.org/cubridapis/php/branches/RB-9.0.0 Revision: 867
{noformat}

codes:
{noformat}
$unescaped_str = ' !#$%\'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$escaped_str = cubrid_real_escape_string($unescaped_str);

$len = strlen($unescaped_str);

$sql = create class escape01(i INT, working_days ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'), answers ENUM('Yes', 'No', 'Cancel'), t char($len));
$req = cubrid_execute($conn, $sql, CUBRID_INCLUDE_OID);

$sql = insert into escape01 values(1,1,1),(2,'Tuesday','No'), (3, 'Wednesday','Cancel'), ('$escaped_str', '$escaped_str', '$escaped_str');
#$req = cubrid_execute($conn, $sql, CUBRID_INCLUDE_OID);
$req = cubrid_execute($conn, $sql);
{noformat}

result
if using the CUBRID_INCLUDE_OID ($req = cubrid_execute($conn, $sql, CUBRID_INCLUDE_OID);), the result is :
{noformat}
Warning: Error: CAS, 2000001, Unknown error message in /home/php/phptestcases/php/php/_19_escape/escape_01.php on line 17
{noformat}

Not using CUBRID_INCLUDE_OID ($req = cubrid_execute($conn, $sql)), the result is :
{noformat}
Warning: Error: DBMS, -494, Semantic: before ' values(1,1,1),(2,'Tuesday','No'), (3, 'Wednesday','Cancel'),...'
The number of attributes(4) and values(3) are not equal. insert into escape01 (i, working_days, answers, t) values (1... in /home/php/phptestcases/php/php/_19_escape/escape_01.php on line 18
{noformat}

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.