- Wed May 03, 2017 5:35 am
#790602
Hello,
What you want to achieve can be done with the code you have shared.
I tried the following code in a trigger which I have placed after Dynaform:
If you want to remove the special characters from the string, you can use:
As I am using the default DB connection, I have not added $db in the code. If you are making a connection to some other database, you can use the code:
Please try this code and run it in debug mode and check if you get a proper SQL query for @@sql and value equal to 1 for @@result.
Hope this helps
Best Regards
Mishika
What you want to achieve can be done with the code you have shared.
I tried the following code in a trigger which I have placed after Dynaform:
Code: Select all
The problem with your code can be here:
$customerName = mysql_real_escape_string(@@textVar002);
@@sql = "INSERT INTO TABLENAME (NAME) VALUES ('$customerName')";
@@result = executeQuery(@@sql) or die ("Error");
Code: Select all
@$customerName will not fetch the value of the variable from Dynaform. You will have to use @@customerName.$customerName = mysql_real_escape_string(@$customerName);
If you want to remove the special characters from the string, you can use:
Code: Select all
instead of $customerName = mysql_real_escape_string(@@textVar002);$customerName = preg_replace('/[^A-Za-z0-9\-]/', '', @@textVar002);
As I am using the default DB connection, I have not added $db in the code. If you are making a connection to some other database, you can use the code:
Code: Select all
This code works perfectly fine for me. It adds the string with special characters as it is to the Database.$db = "<db string>";
$customerName = mysql_real_escape_string(@@textVar002);
@@sql = "INSERT INTO TABLENAME (NAME) VALUES ('$customerName')";
@@result = executeQuery(@@sql, $db) or die ("Error");
Please try this code and run it in debug mode and check if you get a proper SQL query for @@sql and value equal to 1 for @@result.
Hope this helps
Best Regards
Mishika