Jump to content

zsxdcfv21

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zsxdcfv21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. whats the correct way to write this one : $q = "SELECT n.BuyerNoteID, n.Note, date_format(n.Created, '%d %b %y') FROM BuyerNote n LEFT JOIN (Buyer b) ON (b.BuyerID = n.BuyerID AND b.BuyerID = '{$_GET['BuyerID']}') LEFT JOIN (User u) ON (b.UserID = u.UserID) ";
  2. thats the problem.... theres no errors except warning messages....can you pinpoint to me wc do you think is the problem?
  3. got a warning message on line 132. line 132 is in bold letters Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere.com/httpdocs/lib.classes/class.MySQL.php on line 132 <?php class MySQL { var $hostname, $username, $password, $dbName, $dbCn, $sqlQuery, $resultResource; function MySQL( $hostname = 'xxxxx', $username = xxxxx, $password = xxxxx, $dbName = xxxxx) { /*** * this class will check for constants that it requires.. if params were not supplied? */ // init variables $this->hostname = $hostname; $this->username = $username; $this->password = $password; $this->dbName = $dbName; $this->sqlQuery = ''; $this->resultResource = NULL; // connect to db $this->dbCn = mysql_connect($this->hostname, $this->username, $this->password) or $this->error(); // select db mysql_select_db($this->dbName, $this->dbCn) or $this->error(); } function error () { if ( ! class_exists('NiceMail') ) require('class.NiceMail.php'); $mail = new NiceMail('xxxxxxx', 'xxxxxx@xxxxx.com'); $mail->setSubject('Error in ' . $_SERVER["SCRIPT_NAME"] ); $mail->setRecipient('MySQL', 'xxxxxx@xxxxx.com'); $error =  "[MySQL Error!!!]\nErrorNo:"; $error .= mysql_errno() . "\nError:" . mysql_error() . "\n"; $this->password = 'Intentionally removed.'; ob_start(); var_dump( $this ); $error .= ob_get_contents(); ob_end_clean(); $mail->setBody($error); $mail->sendMail(); require('func.error.php'); sendAlert('Globals Dump for MySQL wrapper.'); exit(); } function setQuery ( $queryString ) { // appends to query! $this->sqlQuery .= $queryString; } function execute ( $queryString = NULL ) { // execute the query if ($queryString !== NULL) { $this->setQuery($queryString); } $this->resultResource = mysql_query( $this->sqlQuery ) or $this->error(); // query was successful if this far, reset query $this->sqlQuery = ''; } function executeOrDie ( $queryString = NULL ) { // if no rows return... terminate if ($queryString !== NULL) { $this->setQuery($queryString); } $this->execute(); if ( ! $this->resultHasRows() ) { require('func.error.php'); sendAlert('Execute or Die Died!'); exit(); } return mysql_fetch_object($this->resultResource); } function executeQuietly ( $queryString = NULL ) { // execute the query but don't bounce an error if ($queryString !== NULL) { $this->setQuery($queryString); } $this->resultResource = mysql_query( $this->sqlQuery ); $this->sqlQuery = ''; } function executeQuickly ( $queryString ) { // executes a single string (and appends old sql query) and returns an object..! $this->setQuery( $queryString ); $this->execute(); return $this->getObject(); } function isError () { if ( $this->resultResource === FALSE ) { return TRUE; } else { return FALSE; } } function getErrorNum () { return mysql_errno( $this->dbCn ); } function resultHasRows () { [b]$numRows = mysql_num_rows( $this->resultResource );[/b] if ($numRows) return true; return false; } function getObject () { // fetch a mysql object if any left if ( $object = mysql_fetch_object($this->resultResource) ) { // return the object return $object; } else { // return false and free resource mysql_free_result( $this->resultResource ); return false; } } function getLastInsertId () { $obj = $this->executeQuickly('SELECT LAST_INSERT_ID() LastInsertID'); return (int) $obj->LastInsertID; } function getNumRows () { return mysql_num_rows( $this->resultResource ); } } ?> whats wrong with my script? is it because of resultResource?
  4. is it supposed to be $db->setQuery($q); or $db->execute($q); ???
  5. could u add it for me please? i dont know where to add that line.
  6. i tried taking out the @ in this script : 130 function resultHasRows () 131  { 132      $numRows = @mysql_num_rows( $this->resultResource ); 133      if ( $numRows ) return true; 134      return false;        135  } but then again the warning message is there again : " Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132 " since it mentions about supplied argument, i have to go back to these lines on my other php script  : case 'notes': $q = " SELECT n.NoteID,       n.Note,       date_format(n.Created, '%d %b %y')  nCreated,       date_format(n.Created, '%d %b %y') nModified   FROM BuyerNote n JOIN Buyer b   ON b.BuyerID = n.BuyerID AND b.BuyerID = '{$_GET['BuyerID']}' JOIN User u   ON b.UserID = u.UserID "; if (!$isAdmin) $q .= " AND u.UserID = '{$_SESSION['UserID']}' "; $q .=" ORDER BY n.Created DESC"; [b]if ( true == $db->resultHasRows() ) {[/b] require_once('func.buyernote.php'); $notes = ''; while ( false != ($r = $db->getObject()) ) { $notes .= makeNote($r->BuyerNoteID, nl2br($r->Note), $r->nCreated, $r->nModified); } } else { $notes = 'No Notes to Display.'; } $o = $db->executeOrDie(" select concat(Firstname, ' ', Surname) Name from Buyer where BuyerID = '{$_GET['BuyerID']}' "); // alterted this 18 august if (!$isSubAdmin) $html->setAction("note_add&amp;BuyerID=".$_GET['BuyerID'], 'Add a Note'); $html->setHeading('View Notes for ' . $o->Name); $html->bindContent($notes); $html->useBackButton($_SERVER['PHP_SELF']); $html->printHTML(); $html->serialise(); $db->execute($q); break; see the bold line " if ( true == $db->resultHasRows() ) { " ...i think thats the part it has problem. but i dont get whats the problem... is there something wrong with my $q above ???
  7. hi i did follow the script that u modified : 130 function resultHasRows () 131  { 132      $numRows = mysql_num_rows( $this->resultResource ); 133      if ( $numRows ) return true; 134      return false;        135  } unfortunately, nothings change... i guess the problem is with line 132...remember the warning message? what do u think the warning message for? please help...and thanks for the reply
  8. um... i guess i found it please modify Line 133 and 134 130 function resultHasRows () 131  { 132      $numRows = mysql_num_rows( $this->resultResource ); 133      if ( $numRows ) return true; 134      return false;        135  } ...so how should i modify that down? sorry for being so much innocent on this. can u modify those 2 lines for me?
  9. sorry for being such an ignorant to this. im kinda confused on what you were telling me. ive noticed that the lines : if ( true == $db->resultHasRows() ) { .... } else {       $notes = 'No Notes to Display.'; } are the ones giving me the notes. and again the resutHasRows is involve in there. would that mean that the warning message ago has something to do with this condition if ( true == $db->resultHasRows() ) { thats why i always end up 'No Notes to Display"????
  10. million thanks! as soon as i got that right, it all boils down to this problem if ( true == $db->resultHasRows() ) { require_once('func.buyernote.php'); $notes = ''; while ( false != ($r = $db->getObject()) ) { $notes .= makeNote($r->BuyerNoteID, nl2br($r->Note), $r->nCreated, $r->nModified); } } else { $notes = 'No Notes to Display.'; } ...it always gave me 'No Notes to Display' ...do u think the warning message has anything to do with this? or is it just theres a problem on this line : while ( false != ($r = $db->getObject()) ) { ... please help
  11. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132 130 function resultHasRows () 131   { 132      $numRows = mysql_num_rows( $this->resultResource ); 133      if ( $numRows == 0 ) return false; 134      return true;         135   } how can i hide the warning message? can somebody add a small code to supress or hide the error message?
  12. this is the other script where i could find the resultHasRows() function from the problem above function trackUser() { global $db; if ( @ isset($_SESSION['EventID']) ) { // check for session expiry... $db->setQuery('SELECT EventID FROM SystemUsage WHERE LastPage < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND EventID = '. (int)$_SESSION['EventID']); $db->execute(); // expired! bad javascript no workie if ( $db->resultHasRows() ) { // set sessionedit $db->setQuery('UPDATE SystemUsage SET SessionEND = NOW() WHERE EventID = ' . (int)$_SESSION['EventID']); $db->execute(); // log them out! session_destroy(); header('Location: index.php?expired=1'); exit(); } // otherwise hit the last page! $db->setQuery('UPDATE SystemUsage SET LastPage = NOW() WHERE EventID = ' . (int)$_SESSION['EventID']); $db->execute(); } else { // or.. start a new tracking session... $UserAgent = $_SERVER['HTTP_USER_AGENT']; $RemoteAddr = $_SERVER['REMOTE_ADDR']; $db->setQuery('INSERT INTO SystemUsage (UserID, SessionStart, LastPage, UserAgent, RemoteAddr)'); $db->setQuery(" VALUES (" . (int)$_SESSION['UserID'] . ", NOW(), NOW(), '$UserAgent', '$RemoteAddr')"); $db->execute(); $db->setQuery('SELECT LAST_INSERT_ID() EventID'); $row = $db->executeOrDie(); $_SESSION['EventID'] = $row->EventID; } } wc part do you think has a problem? and if ever theres nothing wrong on that part, is there anyway that i could take out the warning message??? coz as soon as i view this link http://mywebsitehere/app/buyer.php?action=notes&BuyerID=1068, it has a warning message but it display the proper results : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132
  13. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/mywebsitehere/httpdocs/lib.classes/class.MySQL.php on line 132 130 function resultHasRows () 131 { 132 $numRows = mysql_num_rows( $this->resultResource ); 133 if ( $numRows == 0 ) return false; 134 return true; 135 } what are the possible things why it give out a warning???
  14. everytime i visit my link, for example this kind of URL http://www.mywebsitehere.com/app/buyer.php?action=notes&BuyerID=1068 case 'notes': $q = " SELECT n.BuyerNoteID,       n.Note,       date_format(n.Created, '%d %b %y')  nCreated,       date_format(n.Created, '%d %b %y') nModified   FROM BuyerNote n JOIN Buyer b   ON b.BuyerID = n.BuyerID AND b.BuyerID = '{$_GET['BuyerID']}' JOIN User u   ON b.UserID = u.UserID "; if (!$isAdmin) $q .= " AND u.UserID = '{$_SESSION['UserID']}' "; $q .=" ORDER BY n.Created DESC"; $db->execute($q); if ( true == $db->resultHasRows() ) { require_once('func.buyernote.php'); $notes = ''; while ( false != ($r = $db->getObject()) ) { $notes .= makeNote($r->BuyerNoteID, nl2br($r->Note), $r->nCreated, $r->nModified); } } else { $notes = 'No Notes to Display.'; } $o = $db->executeOrDie(" select concat(Firstname, ' ', Surname) Name from Buyer where BuyerID = '{$_GET['BuyerID']}' "); // alterted this 18 august if (!$isSubAdmin) $html->setAction("note_add&amp;BuyerID=".$_GET['BuyerID'], 'Add a Note'); $html->setHeading('View Notes for ' . $o->Name); $html->bindContent($notes); $html->useBackButton($_SERVER['PHP_SELF']); $html->printHTML(); $html->serialise(); break; ... it gives me a blank. no errors or whatsoever, its purely blank. the script for 'func.buyernote.php' are the ff: <? function makeNote ($id, $note, $created) { global $isSubAdmin; $note = <<<endh <table class="note"> <tr> <td valign="top" width="75" class="date"><b>$created</b></td> <td valign="top" class="text" rowspan="2">$note</td> </tr> <tr> <td valign="bottom"> endh; if ( ! $isSubAdmin ) { $note .= <<<endh <a href="buyer.php?action=note_edit&BuyerNoteID=$id">Edit</a> | <a href="buyer.php?action=note_remove&BuyerNoteID=$id">Delete</a> endh; } $note .= "</td></tr></table><br>"; return $note; } ?> can anyone tell me whats wrong??? =(
×
×
  • 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.