Ibshas25 Posted November 26, 2010 Share Posted November 26, 2010 <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; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/ Share on other sites More sharing options...
MrXHellboy Posted November 26, 2010 Share Posted November 26, 2010 $sql.=" LEFT JOIN projects as pr ON prj_id = tea_projectid "; I dont know your table setup but probably its your own fault by defining wrong tables.fields. Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140036 Share on other sites More sharing options...
BlueSkyIS Posted November 26, 2010 Share Posted November 26, 2010 make sure your sql doesn't produce an error: $result = mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140063 Share on other sites More sharing options...
Ibshas25 Posted November 27, 2010 Author Share Posted November 27, 2010 the sql q works fine Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140439 Share on other sites More sharing options...
jcbones Posted November 27, 2010 Share Posted November 27, 2010 The sql doesn't work fine, or you wouldn't get the error you are posting. As was stated above, you have a couple of columns that has no table reference. I bet you are getting "unknown column" issues. Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140442 Share on other sites More sharing options...
JasonLewis Posted November 27, 2010 Share Posted November 27, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140449 Share on other sites More sharing options...
Ibshas25 Posted November 29, 2010 Author Share Posted November 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/219934-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-res/#findComment-1140872 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.