ipgeek-lg Posted June 17, 2012 Share Posted June 17, 2012 Hi, first post so here goes, I have developing an addon module for whmcs and have come across a problem. Part of the addons functionality involves sending an email or two out to clients. The problem I am having is using the _activate function to run an sql query to put pre-defined email templates into the DB. So far I have the following for the query: $sqlEmail1 = "INSERT INTO `tblemailtemplates` (`type`, `name`, `subject`, `message`, `attachments`, `fromname`, `fromemail`, `disabled`, `custom`, `language`, `copyto`, `plaintext`) VALUES ('general', 'IPGeek - Custom Email 1', 'Password Reset', 'Some text that contains {$company_name} among other things', '', '', '', '', '1', '', '', 0)" Now the problem with this is using " to contain the SQL query with {$company_name} in it makes php try to insert the previously defined variable {$company_name} when actually running the SQL query. I could change to 'INSERT.... but this then means using ' to contain field values ('Password Reset') would not be a possibility. Anyone got any ideas? 0 Quote Link to comment Share on other sites More sharing options...
ipgeek-lg Posted June 17, 2012 Author Share Posted June 17, 2012 --UPDATE-- Tried using the insert_query() function to no avail: $table = "tblemailtemplates"; $values = array("type"=>"general","name"=>"IPGeek - First Email","subject"=>"Password Reset","message"=>'{$company_name} among other things.</p>',"custom"=>"1","plaintext"=>0); $newid = insert_query($table,$values); 0 Quote Link to comment Share on other sites More sharing options...
ipgeek-lg Posted June 17, 2012 Author Share Posted June 17, 2012 --UPDATE-- Managed to do this with the help of some guys over at StackOverflow: $email_templates = "INSERT INTO `tblemailtemplates` (`type`, `name`, `subject`, `message`, `attachments`, `fromname`, `fromemail`, `disabled`, `custom`, `language`, `copyto`, `plaintext`) VALUES ('general', 'IPGeek Security - PWRESET - First Email', 'Password Reset', '<p>Dear {\$client_name}</p><p>A request has been received by {\$company_name} for your account password to be reset. If you did not initiate this request then please get in contact with our support department.</p>', '', '', '', '', '1', '', '', 0)"; $result = mysql_query($email_templates); So the $ was escaped and we are able to use " to enclose the SQL query. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.