This topic is locked

Insert field (mediumtext) with punctuation into another table

5/7/2016 4:30:30 PM
PHPRunner General questions
H
Hopper author

The following event works fine unless the comment field has punctuation in it. Then the insert returns and error. I am not having any luck on figuring out how to insert the comment field with punctuation. Any help is greatly appreciated.
Thanks
global $conn;

$strSQLInsert = "insert into otr_log (otr_id, uid, comment) values (".$values["rid"].",'".$values["approver_uid"]."','".$values["approver_comments"]."')";

db_exec($strSQLInsert,$conn);
php error happened

Error type 256

Error description You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's like snap')' at line 1

Error line 142

SQL query insert into otr_log (otr_id, uid, comment) values (116,'147','Look's like snap')

Sergey Kornilov admin 5/9/2016

You need to use prepareString() function for this purpose:

global $conn;

$strSQLInsert = "insert into otr_log (otr_id, uid, comment) values (".$values["rid"].",'".$values["approver_uid"]."','".$conn->prepareString($values["approver_comments"])."')";

db_exec($strSQLInsert,$conn);
H
Hopper author 5/9/2016

Hi Sergey.
I made the change and I am getting the following error.
Fatal error: Call to undefined method mysqli::prepareString() in /..../include/OTR_eApprove_events.php on line 297
----

PHPRunner: 8.1 25268 x64

Database: MariaDB 10.0

PHP: 5.6
Thank you for any assistance.

Sergey Kornilov admin 5/13/2016

Try the following:

$strSQLInsert = "insert into otr_log (otr_id, uid, comment) values (".$values["rid"].",'".$values["approver_uid"]."','".$pageObject->connection->prepareString($values["approver_comments"])."')";

CustomQuery($strSQLInsert);
H
Hopper author 5/26/2016

Hi Sergey.
I tried the revised event code and the following error is now being returned:
Error type 256

Error description You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'This is the additional information.'')' at line 1

URL OTR_eApprove_edit.php?submit=1&editid1=128&

Error file /nfi/overtime/connections/MySQLiConnection.php

Error line 142

SQL query insert into otr_log (otr_id, uid, comment) values (128,'147',''This is the additional information.'')

H
Hopper author 6/1/2016

Hi Sergey.
Any other ideas?
Thanks

Sergey Kornilov admin 6/1/2016

You need to post your project to demo account and contact support directly.