MySQL Forums
Forum List  »  PHP

Re: PHP creates query that has to be edited before it will run in MySql
Posted by: Peter Brawley
Date: May 07, 2015 03:54PM

Much simpler than fussing with all those quotes and concatenations:

$query = "
SELECT `recId`,`key`,`IDno`,`VendorId`,`AccountNo`, `Category`,
`Internet`,`Internet2`, `Company`, `Email`,`Email2`,`Phone`,
des_decrypt(`internetid`, 'alibaba511')AS 'internetid',
des_decrypt(`PW`, 'alibaba511') AS 'PW',
des_decrypt(`licensekeypin`, 'alibaba511') AS 'license',
`EmailOfRecord`, `Hints`
FROM `account` WHERE `Company`= 'Fay School'
";

And you could simplify your life further by adopting the convention of never using reserved words like `key` as column names, so you could skip all those bug-inviting backticks, eg ...

$query = "SELECT recId, thekey, IDno, VendorId, AccountNo, Category,
Internet,Internet2, Company, Email,Email2,Phone,
des_decrypt(internetid, 'alibaba511')AS 'internetid',
des_decrypt(PW, 'alibaba511') AS 'PW',
des_decrypt(licensekeypin, 'alibaba511') AS 'license',
EmailOfRecord, Hints
FROM account WHERE Company= 'Fay School'
";

Options: ReplyQuote


Subject
Written By
Posted
Re: PHP creates query that has to be edited before it will run in MySql
May 07, 2015 03:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.