problem with fetching results from mysql via php function -


can 1 point out problem code? supposed fetch data mysql returns blank. here full code.

<ul class="list">  <?php  require("object/db.class.php");  error_reporting(0);  function entry_tickets() {  if($_session['dojopress_global:root'] == false) {  $entry_ticket .= <<<entry_ticket <li><p><img src="http://cdn1.iconfinder.com/data/icons/humano2/32x32/apps/gnome-keyring-manager.png" />access denied</p></li> entry_ticket;  } elseif($_session['dojopress_global:root'] == true) {  $q = "select * `notice` order nid limit 12 desc"; $r = mysql_query($q);  if ( mysql_num_rows($r) == 0 ) {  $entry_ticket .= <<<entry_ticket <li><p><img src="http://cdn1.iconfinder.com/data/icons/humano2/32x32/status/dialog-information.png" /> nothing display</p></li> entry_ticket;  } elseif ( $r !== false && mysql_num_rows($r) > 0 ) {     while ( $a = mysql_fetch_array($r) ) {          $nid = stripslashes($a['nid']);         $note = stripslashes($a['note']);         $type = stripslashes($a['type']);         $private = stripslashes($a['private']);         $date = stripslashes($a['date']);         $author = stripslashes($a['author']);       function note_type($type) {         if($type == 1) { $type = "posted comment!"; } elseif($type == 2) { $type = "raised support ticket!"; } else { }        return ($type);     }  $entry_ticket .= <<<entry_ticket <li><p><a href="viewer.php?nid=$nid" id="record-$nid"> $athor, note_type($type)</a></p></li> entry_ticket;      return $entry_ticket;      } }   } }  echo entry_tickets();  ?>  </ul>  <div style="clear:both;height:10px;"></div> 

sorry forgot db.class.php

<?php session_start(); //connect.php $host = "localhost"; $db_user = "root"; $db_pass = ""; $db_name = "au";  $connectclass = mysql_connect("$host", "$db_user", "$db_pass") or die ("couldn't establish connection database server."); $dbobject = mysql_select_db("$db_name", $connectclass) or die ("couldn't select database."); ?> 

error reporting disabled error code

warning: mysql_num_rows(): supplied argument not valid mysql result resource in d:\wamp\www\ageis\note.php on line 22 

your mysql syntax looks bad. have:

 select * `notice` order nid limit 12 desc 

try

 select * `notice` order nid desc limit 12 

erik's comments should have pointed in right direction, however:

  1. figure out php logs errors. either turn php's error reporting level see more errors, or start tailing apache error_log
  2. you should check errors after running mysql_query , sort of logging on failure. best accomplished writing wrapper function mysql_query this, or using 3rd party db wrapper has solved problem.

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -