Error in your SQL syntax
nickelfred
Messages postés
1
Statut
Membre
-
Sniper11 -
Sniper11 -
Bonjour,
configuration sous xampp, mysql 5.1.37, apache 2.2.12, php 5.3.0
j'ai le message suivant :
Invalid query: 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 ''rights' WHERE 'id_folder' IN (\11\12\13\,0)' at line 1
Query: SELECT CONCAT('id_user','-','id_folder'), 'rights' FROM dm_'rights' WHERE 'id_folder' IN (\11\12\13\,0);
j'ai isolé la partie du code qui semble en cause :
function listUsersWithFolderAccess($folder) {
$folder=intval($folder);
$fp=array();
if ($folder) {
// First, we list the folders_id in the path, in reverse side order (from the deeper folder_id up to the root)
$fp=queryOneField("SELECT folder_path FROM " . TABLE_PREFIX . "folders WHERE id_folder='$folder';");
if (substr($fp,0,1)=="/") $fp=substr($fp,1);
if (substr($fp,-1,1)=="/") $fp=substr($fp,0,-1);
$fp=array_reverse(explode("/",$fp)); // Here we have the folder id list
}
$fp[]=0;
$q = "SELECT CONCAT(id_user,'-',id_folder), rights FROM " . TABLE_PREFIX . "rights WHERE id_folder IN (".implode($fp,",").");";
$allrights=queryAssoc($q);
// Then, for each user, we check in this order that the user has the rights
$q = "SELECT * FROM " . TABLE_PREFIX . "users ORDER BY user_name ASC";
$r = mysql_query($q);
$listUsers=array();
while ($c=mysql_fetch_array($r)) {
// Check the user's rights
$hasright=false;
foreach($fp as $fid) {
if (isset($allrights[$c["id_user"]."-".$fid])) {
if (strpos($allrights[$c["id_user"]."-".$fid],"r")!==false) {
$hasright=true;
quelqu'un peut-il m'en dire un peu plus, j'ai essayé de modifier la syntaxe de la ligne en question sans grand succes....
Merci par avance de vos réponses
configuration sous xampp, mysql 5.1.37, apache 2.2.12, php 5.3.0
j'ai le message suivant :
Invalid query: 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 ''rights' WHERE 'id_folder' IN (\11\12\13\,0)' at line 1
Query: SELECT CONCAT('id_user','-','id_folder'), 'rights' FROM dm_'rights' WHERE 'id_folder' IN (\11\12\13\,0);
j'ai isolé la partie du code qui semble en cause :
function listUsersWithFolderAccess($folder) {
$folder=intval($folder);
$fp=array();
if ($folder) {
// First, we list the folders_id in the path, in reverse side order (from the deeper folder_id up to the root)
$fp=queryOneField("SELECT folder_path FROM " . TABLE_PREFIX . "folders WHERE id_folder='$folder';");
if (substr($fp,0,1)=="/") $fp=substr($fp,1);
if (substr($fp,-1,1)=="/") $fp=substr($fp,0,-1);
$fp=array_reverse(explode("/",$fp)); // Here we have the folder id list
}
$fp[]=0;
$q = "SELECT CONCAT(id_user,'-',id_folder), rights FROM " . TABLE_PREFIX . "rights WHERE id_folder IN (".implode($fp,",").");";
$allrights=queryAssoc($q);
// Then, for each user, we check in this order that the user has the rights
$q = "SELECT * FROM " . TABLE_PREFIX . "users ORDER BY user_name ASC";
$r = mysql_query($q);
$listUsers=array();
while ($c=mysql_fetch_array($r)) {
// Check the user's rights
$hasright=false;
foreach($fp as $fid) {
if (isset($allrights[$c["id_user"]."-".$fid])) {
if (strpos($allrights[$c["id_user"]."-".$fid],"r")!==false) {
$hasright=true;
quelqu'un peut-il m'en dire un peu plus, j'ai essayé de modifier la syntaxe de la ligne en question sans grand succes....
Merci par avance de vos réponses