我不明白发生了什么。我在PHP中有一个查询崩溃 - 有一个奇怪的错误 - 。当我在PHPMyAdmin中复制/粘贴完全相同的请求时,它按预期工作。 我在这里做错了什么?
SELECT oms_patient.id,
oms_patient.date,
oms_patient.date_modif,
date_modif,
AES_DECRYPT(nom,"xxxxx") AS "Nom",
AES_DECRYPT(prenom,"xxxxx") AS "Prénom usuel",
DATE_FORMAT(ddn, "%d/%m/%Y") AS "Date de naissance",
villeNaissance AS "Lieu de naissance (ville)",
CONCAT(oms_departement.libelle,"(",id_departement,")") AS "Lieu de vie",
CONCAT(oms_pays.libelle,"(",id_pays,")") AS "Pays",
CONCAT(patientsexe.libelle,"(",id_sexe,")") AS "Sexe",
CONCAT(patientprofession.libelle,"(",id_profession,")") AS "Profession",
IF(asthme>0,"Oui","Non") AS "Asthme",
IF(rhinite>0,"Oui","Non") AS "Rhinite",
IF(bcpo>0,"Oui","Non") AS "BPCO",
IF(insuffisanceResp>0,"Oui","Non") AS "Insuffisance respiratoire chronique",
IF(chirurgieOrl>0,"Oui","Non") AS "Chirurgie ORL du ronflement",
IF(autreChirurgie>0,"Oui","Non") AS "Autre chirurgie ORL",
IF(allergies>0,"Oui","Non") AS "Allergies",
IF(OLD>0,"Oui","Non") AS "OLD",
IF(hypertensionArterielle>0,"Oui","Non") AS "Hypertension artérielle",
IF(infarctusMyocarde>0,"Oui","Non") AS "Infarctus du myocarde",
IF(insuffisanceCoronaire>0,"Oui","Non") AS "Insuffisance coronaire",
IF(troubleRythme>0,"Oui","Non") AS "Trouble du rythme",
IF(accidentVasculaireCerebral>0,"Oui","Non") AS "Accident vasculaire cérébral",
IF(insuffisanceCardiaque>0,"Oui","Non") AS "Insuffisance cardiaque",
IF(arteriopathie>0,"Oui","Non") AS "Artériopathie",
IF(tabagismeActuel>0,"Oui","Non") AS "Tabagisme actuel",
CONCAT(nbPaquetsActuel," ","PA") AS "",
IF(tabagismeAncien>0,"Oui","Non") AS "Tabagisme ancien",
CONCAT(nbPaquetsAncien," ","PA") AS "",
IF(alcool>0,"Oui","Non") AS "Alcool (conso régulière)",
IF(refluxGastro>0,"Oui","Non") AS "Reflux gastro-oesophagien",
IF(glaucome>0,"Oui","Non") AS "Glaucome",
IF(diabete>0,"Oui","Non") AS "Diabète",
CONCAT(patienttypeDiabete.libelle,"(",id_typeDiabete,")") AS "",
IF(hypercholesterolemie>0,"Oui","Non") AS "Hypercholestérolémie",
IF(hypertriglyceridemie>0,"Oui","Non") AS "Hypertriglycéridémie",
IF(dysthyroidie>0,"Oui","Non") AS "Dysthyroïdie",
IF(depression>0,"Oui","Non") AS "Dépression",
IF(sedentarite>0,"Oui","Non") AS "Sédentarité",
IF(syndromeDApneesSommeil>0,"Oui","Non") AS "SAS",
IF(obesite>0,"Oui","Non") AS "Obésité",
IF(dysmorphieFaciale>0,"Oui","Non") AS "Dysmorphie faciale",
TextObservations AS "",
id_user
FROM oms_patient
LEFT JOIN oms_departement ON oms_departement.id = id_departement
LEFT JOIN oms_pays ON oms_pays.id = id_pays
LEFT JOIN patientsexe ON patientsexe.id = id_sexe
LEFT JOIN patientprofession ON patientprofession.id = id_profession
LEFT JOIN patienttypeDiabete ON patienttypeDiabete.id = id_typeDiabete
WHERE oms_patient.id=1
您的SQL语法有错误;检查对应的手册 到你的MySQL服务器版本,以便在附近使用正确的语法 'small'>(consorégulière)“,IF(refluxGastro> 0,”Oui“,”Non“)as”Reflux ga'在第1行
“靠近'小”< - 其中小o_O
PHP代码并不真正相关,因为你不会看到太多。
$db = mysql_connect();
mysql_select_db();//TODO SWITCH TO PDO
mysql_query("SET NAMES UTF8");
$fields = $form->getFields($form);
$settingsForm = $form->getSettings();
$sql = 'SELECT oms_patient.id,oms_patient.date,oms_patient.date_modif,';
foreach ($fields as $field) {
if (!$field->isMultiSelect()) {
$field->select_full(&$sql, 'oms_patient', null);
}
}
if (isset($settingsForm['linkTo'])) {
$idLinkTo = 'id_' . str_replace('oms_', '', $settingsForm['linkTo']);
$sql .= $idLinkTo;
}
$sql.=' FROM oms_patient';
foreach ($fields as $field) {
if (!$field->isMultiSelect() && $field->getTable('oms_patient')) {
$sql .=' LEFT JOIN ' . $field->getTable('oms_patient') . ' ON ' . $field->getTable('oms_patient') . '.id = '.$field->getFieldName().' ';
}
}
$sql.=' where oms_patient.id=' . $this->m_settings['e'];
$result = mysql_query($sql) or die('Erreur SQL !<br>' . $sql . '<br>' . mysql_error());
$data = mysql_fetch_assoc($result);
$ sql的var_dump
string(2663) "SELECT oms_patient.id,oms_patient.date,oms_patient.date_modif,date_modif,AES_DECRYPT(nom,"xxxxx") as "Nom",AES_DECRYPT("prenom","xxxxx") as "Prénom usuel",DATE_FORMAT(ddn, "%d/%m/%Y") as "Date de naissance",villeNaissance as "Lieu de naissance (ville)",CONCAT(oms_departement.libelle,"(",id_departement,")") as "Lieu de vie",CONCAT(oms_pays.libelle,"(",id_pays,")") as "Pays",CONCAT(patientsexe.libelle,"(",id_sexe,")") as "Sexe",CONCAT(patientprofession.libelle,"(",id_profession,")") as "Profession", IF"...
无法进一步查看“...”之后输出中的内容&lt; - 如果您有想法
答案 0 :(得分:3)
您的问题很可能是在SELECT
字段中,您正在注入HTML标记。
我不确切知道这个函数的作用:$field->select_full(&$sql, 'oms_patient', null);
,但它很可能附加包含HTML标记的字符串。
如果您执行var_dump($sql);
,则会清楚地看到这一点,然后一旦在浏览器中看到它,请右键单击 - >查看来源。在源代码中,您将在查询之间看到HTML标记。
修复此问题,您将解决问题。