MySQL Forums
Forum List  »  PHP

PHP creates query that has to be edited before it will run in MySql
Posted by: rick pizzi
Date: May 07, 2015 02:14PM

My PHP program generates a query as follows:

MY code:

$strA="`IDno`,`VendorId`,`AccountNo`,";
$strB.="`Category`,`Internet`,`Internet2`,";
$strB= "`Company`, `Email`,`Email2`,`Phone`, ";
$strB.="des_decrypt(`internetid`, '".$key."') AS 'internetid', ";
$strB.="des_decrypt(`PW`, '".$key."') AS 'PW', ";
$strB.="des_decrypt(`licensekeypin`, '".$key."') AS 'license', ";
$strB.="`EmailOfRecord`,`Hints`";

$str=$strA.$strB;

$query = "SELECT ".$str." FROM `account` WHERE `IDno`= '".$recId."';";

MySql query produced:

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';

Notice how the line splits:

.... `Company
`, `Email`, ...... where the closing ` in `Company` falls on another line.

the query then won't work. It must be edited to work.

In the code above the $strA, $strB is just an attempt to get $query to produce a MySql query that will work. How can I code this so this doesn't happen?


Thanks,

R

Options: ReplyQuote


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


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.