Hi all,When mailing the data (1,2) that comes with a comma from the lookup table, I get the following error:C:\inetpub\wwwroot\app\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php(98): An exception occurred while executing ‘SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID =1,2’: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘,2’ at line 1field where I get data from lookup table = ContactTypes (varchar,255 and sample field data= 1,2) (phpmaker lookup table field settings = select & multiple)
lookup table = contacttypes
ContactTypeID, ContactTypeEN, ContactTypeFR
1, Eng_item1, Fra_item2,
2, Eng_item1, Fra_item2,
mail_sending code:" . ExecuteScalar(“SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID = explode(‘’,” “. CurrentPage()->ContactTypes ->CurrentValue .”)") . "I know very well that I wrote this code wrong, which examples should I look for for the right method?
Double check your code:
ContactTypeID = explodeIt should be:
ContactTypeID = " . explodeand adjust the closing part of that explode function code, too.
I re-edited the code as you said. The page worked without any errors, but when sending mail it gave the following error." . ExecuteScalar(“SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID = " . explode(”,", CurrentPage()->ContactTypes ->CurrentValue). “”) . "Error:
C:\inetpub\wwwroot\app\src\DbTableBase.php(395): Undefined property: ContactTypes.
Because in Email_Sending server event, you should use the following code in order to get the value from the certian field, for example:$myValue = $args[“rsnew”][“ContactTypes”];or if it does not work, you may try the following one instead:$myValue = $args[“rsold”][“ContactTypes”];You may read Server Events and Client Scripts topic from PHPMaker Help menu, and see Email_Sending section for more info and example.You may post your complete code in Email_Sending server event for more discussion.
I don’t have a problem with if, else, true false conditions. Mail function is working. The problem is I just can’t get the data in the type I want as I mentioned above.when i run it like this the error code is:C:\inetpub\wwwroot\app\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php(79): An exception occurred while executing ‘SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID = Array’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘Array’ in ‘where clause’
You should not use this code in Email_Sending server event: CurrentPage()->ContactType->CurrentValueYou should use the code that I suggested to you above.
well,
Please assume that an email is sent each time the record is edited.
When I use $args[“rsnew”] it throws an error if the existing data is not updated.
The $args[“rsold”] code always just sends the old value of the data.
There is a possibility that the data of the field may be updated. I have to use “CurrentPage()->MyField->CurrentValue” to always send the current value of the data.Is there something I don’t understand about the $args thing? I can’t use the $args event to always send the current value of the field.
// Email Sending event
function Email_Sending($email, &$args)
if (CurrentPageID() == "edit") {
if ($args["rsnew"]["Contacted"] == "1") {
$myValue = $args["rsold"]["ContactTypes"];
$email->Sender = CurrentUserInfo("Email")";
$email->Recipient = "group@argustour.com";
$email->Subject = "Contacted";
$email->Content = " . ExecuteScalar("SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID = " . explode(",",$myValue) . "") . "
if ($args["rsold"]["Contacted"] == "1") return false;
} else {
return false;
}
}
Error code:
C:\inetpub\wwwroot\app\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php(79): An exception occurred while executing ‘SELECT ContactTypeFR FROM contacttypes WHERE ContactTypeID = Array’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘Array’ in ‘where clause’
Unfortunately I found such complex solution as I can’t generate syntax, string, query code.
I placed the field function created by phpmaker inside the email function and thus I was able to send the view value to the email.
I read the documentation to learn the explode() function. I looked at what can be done with the explode function with the obtained data.Moreover, I understood from the help document that I should do this with ExecuteRows, not ExecuteScalar.You’ve been very helpful up to this point. Thanks.