gmc1103 Posted February 9, 2015 Share Posted February 9, 2015 Hi Can someone help me with this <table id="dg" class="easyui-datagrid" url="get_atividadesByUserId.php?=<?php echo $userid ?>" style="width:1800px;height:500px; border:1px solid #ccc;" title="Gestão das Atividades" toolbar="#toolbar" pagination="true" idField="id" rownumbers="true" fitColumns="true" resizable="true"> <thead> <tr> <th field="idativade" width="20">Nº</th> <th field="cargo" width="200">Cargo</th> <th field="atividade" width="200">Atividade</th> <th field="data" width="50">Data</th> <th field="hora" width="50">Hora</th> <th field="local" width="100">Local</th> <th field="inter" width="200">Intervenientes</th> <th field="notas" width="150">Notas</th> </tr> </thead> </table> and my php <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $iduser= $_GET['userid']; include 'conn.php'; mysql_query("SET NAMES 'utf8'"); $rs = mysql_query('SELECT `pae_atividades`.`idativade` , `pae_cargo`.`cargo` , `pae_atividades`.`atividade` , `pae_atividades`.`data` , `pae_atividades`.`hora` , `pae_atividades`.`local` , `pae_atividades`.`inter` , `pae_atividades`.`notas` , `utilizador`.`nome` FROM `ebspma_paad_ebspma`.`pae_atividades` INNER JOIN `ebspma_paad_ebspma`.`utilizador` ON ( `pae_atividades`.`idutilizador` = `utilizador`.`idutilizador` ) INNER JOIN `ebspma_paad_ebspma`.`pae_cargo` ON ( `pae_atividades`.`idcargo` = `pae_cargo`.`idcargo` ) WHERE `pae_atividades`.`data` >= CURDATE( ) AND `pae_atividades`.`idutilizador`= $iduser ORDER BY `pae_atividades`.`data` ASC '); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?> I'm getting this error <br /> <b>Notice</b>: Undefined index: userid in <b>/home/ebspma/public_html/atividades/get_atividadesByUserId.php</b> on line <b>4</b><br /> <br /> <b>Warning</b>: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in <b>/home/ebspma/public_html/atividades/get_atividadesByUserId.php</b> on line <b>14</b><br /> [] The url passed is right get_atividadesByUserId.php?=1261 i have the id correct so whats wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/ Share on other sites More sharing options...
cyberRobot Posted February 9, 2015 Share Posted February 9, 2015 The name of the GET variable is missing. Try changing this get_atividadesByUserId.php?=1261 To this get_atividadesByUserId.php?userid=1261 Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505249 Share on other sites More sharing options...
gmc1103 Posted February 9, 2015 Author Share Posted February 9, 2015 Thank you The first error has gone but i still have the second <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $iduser= $_GET['userid']; include 'conn.php'; mysql_query("SET NAMES 'utf8'"); $rs = mysql_query('SELECT `pae_atividades`.`idativade` , `pae_cargo`.`cargo` , `pae_atividades`.`atividade` , `pae_atividades`.`data` , `pae_atividades`.`hora` , `pae_atividades`.`local` , `pae_atividades`.`inter` , `pae_atividades`.`notas` , `utilizador`.`nome` FROM `ebspma_paad_ebspma`.`pae_atividades` INNER JOIN `ebspma_paad_ebspma`.`utilizador` ON ( `pae_atividades`.`idutilizador` = `utilizador`.`idutilizador` ) INNER JOIN `ebspma_paad_ebspma`.`pae_cargo` ON ( `pae_atividades`.`idcargo` = `pae_cargo`.`idcargo` ) WHERE `pae_atividades`.`data` >= CURDATE( ) AND `pae_atividades`.`idutilizador`= $iduser ORDER BY `pae_atividades`.`data` ASC '); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?> Line 14 Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/ebspma/public_html/atividades/get_atividadesByUserId.php on line 14[] Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505251 Share on other sites More sharing options...
cyberRobot Posted February 9, 2015 Share Posted February 9, 2015 Sorry about that...I didn't see the second error message in your original post. Did you check if MySQL is throwing any errors? More information about doing that can be found here: http://php.net/manual/en/function.mysql-error.php Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505256 Share on other sites More sharing options...
Tom10 Posted February 9, 2015 Share Posted February 9, 2015 (edited) Thank you The first error has gone but i still have the second <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $iduser= $_GET['userid']; include 'conn.php'; mysql_query("SET NAMES 'utf8'"); $rs = mysql_query('SELECT `pae_atividades`.`idativade` , `pae_cargo`.`cargo` , `pae_atividades`.`atividade` , `pae_atividades`.`data` , `pae_atividades`.`hora` , `pae_atividades`.`local` , `pae_atividades`.`inter` , `pae_atividades`.`notas` , `utilizador`.`nome` FROM `ebspma_paad_ebspma`.`pae_atividades` INNER JOIN `ebspma_paad_ebspma`.`utilizador` ON ( `pae_atividades`.`idutilizador` = `utilizador`.`idutilizador` ) INNER JOIN `ebspma_paad_ebspma`.`pae_cargo` ON ( `pae_atividades`.`idcargo` = `pae_cargo`.`idcargo` ) WHERE `pae_atividades`.`data` >= CURDATE( ) AND `pae_atividades`.`idutilizador`= $iduser ORDER BY `pae_atividades`.`data` ASC '); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?> Line 14 Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/ebspma/public_html/atividades/get_atividadesByUserId.php on line 14 [] mysql is deprecated you should use mysqli, have you tried while($row = mysql_fetch_object($result)){ array_push($result, $row); } Your trying to get the result from the query without actually getting the results Also, $result = $rs->fetch(); Edited February 9, 2015 by Tom10 Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505264 Share on other sites More sharing options...
cyberRobot Posted February 9, 2015 Share Posted February 9, 2015 mysql is deprecated you should use mysqli... ...or PDO. More information about the different APIs can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php ...have you tried while($row = mysql_fetch_object($result)){ array_push($result, $row); } Based on the code originally posted, the resultset is being saved to the $rs variable. $rs = mysql_query('SELECT `pae_atividades`.`idativade` ... ORDER BY `pae_atividades`.`data` ASC '); $result contains something else. Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505269 Share on other sites More sharing options...
Solution gmc1103 Posted February 10, 2015 Author Solution Share Posted February 10, 2015 Hi No, it was a double quote error...sorry Thanks Quote Link to comment https://forums.phpfreaks.com/topic/294476-php-error/#findComment-1505326 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.