Jump to content

<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL res


Ibshas25

Recommended Posts

<b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/export/SOI-50/students/m2009/abhr428/web/WebIbs/prjlistmenuPBT.php</b> on line <b>36</

 

 

just cant seem to get this to work.. help?????

 

 

 


<?php
include("JSON.php"); 
require_once("connectdb.php"); 


$req = json_decode(stripslashes($_POST['data']), true);

$req["SuccFail"]="fail";
$req["SuccFailMessage"]="Error Occured.";
$req["ResultData"]="";
//$logFile = 'logFile';
//error_log("isl=baþladý: ", 3, $logFile);

if ($req['operation'] == "prjsearch") // select için veri geldi
{
   // error_log("isl==select oluþuyor: ", 3, $logFile);
    $sql= "SELECT  pr.prj_id, pr.prj_projectname ,pr.prj_startdate,med_description, tea_rolId, ";

$sql.=" DATE_FORMAT(prj_startdate,'%d-%m-%Y') as prj_startdate, DATE_FORMAT(prj_enddate,'%d-%m-%Y') as prj_enddate , CASE prj_iscompleted WHEN 'Y' THEN 'Completed' WHEN 'N' THEN 'Not Completed' else 'Undefined' end as prj_iscompleted 
  from teams ";

 $sql.=" LEFT JOIN projects as pr ON prj_id = tea_projectid  ";
   
   $sql.=" LEFT JOIN metodology as med ON med.med_id  =  pr.prj_metodid " ;
   
   $sql.="  WHERE tea_userId =".$req["userid"];  
   
   $sql.=" GROUP by pr.prj_id, pr.prj_projectname,pr.prj_startdate
  order by  pr.prj_startdate desc ";
  
  //error_log($sql, 3, $logFile);
    $result = mysql_query($sql);

    $reslist = "<table border='1'><tr><th>Project Id</th><th>Name</th><th>Methodology</th><th>Start Date</th><th>End date</th><th>Condition</th></tr>";
    
   while($row = mysql_fetch_array($result))
   {
	// error_log("user: ".$row['usr_name']." surname :".$row['usr_username'], 3, $logFile);
$reslist .= "<tr><td><a href='#'onclick='javascript:PrjSearchChoose(".$row['prj_id'].", ".$row['tea_rolId'].");' >".$row['prj_id']."</a></td><td>".$row['prj_projectname']."</td><td>".$row['med_description']."</td><td> ".$row['prj_startdate']."</td><td>".$row['prj_enddate']."</td><td>".$row['prj_iscompleted']."</td> </tr>";

   }
  // error_log($reslist, 3, $logFile);
	// error_log("$reslist: ".$reslist, 3, $logFile);
   $reslist .= "</table>";
   $req["SuccFail"]="success"; //operation success or fail
   $req["SuccFailMessage"]="successfully selected.";
   //alert($reslist);
   $req["ResultData"]=$reslist;
     mysql_close($conn); 
   header("Content-type: text/plain");
   echo json_encode($req); 
   return;
   
   } 
   else if ($req['operation'] == "setuserrights") // set user rights
   {
   
       $sql= "select rol_projectMng, rol_teamsMng,rol_rolesMng,rol_usersMng,rol_metodMng,rol_ranklevel from roles where rol_Id = ".$req["rolid"];

// error_log($sql, 3, $logFile);

    $result=mysql_query($sql);
$row=mysql_fetch_array($result);

//if username exists
if(mysql_num_rows($result)>0)
{ 
   $req["SuccFail"]="success"; //operation success or fail
   $req["SuccFailMessage"]="user rights come.";
   //$row = mysql_fetch_array($result)
   //select rol_projectMng, rol_teamsMng,rol_rolesMng,rol_usersMng,rol_metodMng,rol_ranklevel from roles where rol_Id = 3
   $_SESSION['projectMng']=$row['rol_projectMng']; 
   $_SESSION['teamsMng']=$row['rol_teamsMng']; 
   $_SESSION['rolesMng']=$row['rol_rolesMng']; 
   $_SESSION['usersMng']=$row['rol_usersMng']; 
   $_SESSION['metodMng']=$row['rol_metodMng']; 
   $_SESSION['rol_ranklevel']=$row['rol_ranklevel']; 
   $req["SuccFailMessage"]=$row['rol_projectMng'].$row['rol_teamsMng'].$row['rol_rolesMng'].$row['rol_usersMng'].$row['rol_metodMng'].$row['rol_ranklevel'];
   mysql_close($conn); 
   //error_log($row['rol_ranklevel'].",".$row['projectMng'] , 3, $logFile);
   header("Content-type: text/plain");
   echo json_encode($req); 
   return;

}
else {
   header("Content-type: text/plain");
   echo json_encode($req); 
   //error_log("invalid", 3, $logFile); 
   return;	
}

   }
   
   

     
?>


Link to comment
Share on other sites

the sql q

works fine

The error you stated in your first post clearly points out that your MySQL is not working. If mysql_fetch_array() is telling you that the 1st parameter is not a valid resource, your query is failing which means you have an error somewhere in your query.

Link to comment
Share on other sites

the error is now solved.. there was nothing wronge with the sql as i stated before even with the error was pointing towards this. when using a unix based system dreamweaver does not provide the code line breaking for unix. once doing this it all started to work.

 

thanks for your feedback guys.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.