nickelus Posted June 8, 2010 Share Posted June 8, 2010 Anyone see what's wrong here? I've been making various changes with no success, the error is at line 147, its the goto() method <?php class DB_Result { private $id; // The ID that was created as a result of inserting a row private $length = 0; // The size of the resultset private $result; // The result itself private $currentRow = array(); // The row at our current position in the resultset private $position = 0; // Current position private $lastPosition = 0; // The last position we were at when we read from the resultset private $gotResult = false; // If we have pulled out any rows or not yet private $affectedRows = -1; // The affected number of rows from the query /** * Constructor * @param result result * @param resource connection * @param boolean insert query */ public function __construct(&$result, &$conn, $insert=false) { $this->result = $result; $this->conn = $conn; if ((@mysql_num_rows($this->result) >= 0 && $this->result !== false) || $insert) { if ($insert) $this->id = mysql_insert_id($conn); $this->length = (int) @mysql_num_rows($this->result); $this->affectedRows = mysql_affected_rows($conn); } } /** * Magic overloaded method. * Returns data from the resultset * @param string column */ public function __get($field) { if ($this->lastPosition != $this->position || !$this->gotResult) { mysql_data_seek($this->result, $this->position); $this->currentRow = mysql_fetch_assoc($this->result); $this->lastPosition = $this->position; $this->gotResult = true; } return $this->currentRow[$field]; } /** * Get the insert id */ public function id() { return $this->id; } /** * Size of the resultset */ public function length() { return $this->length; } /** * Go to the first row of the resultset * @return boolean */ public function first() { if ($this->length > 0) { $this->goto(0); return true; } else return false; } /** * Go to the last row of the resultset * @return boolean */ public function last() { return $this->goto($this->length-1); } /** * Check if we've reched the end of the resultset * @return boolean */ public function end() { if ($this->position >= $this->length) return true; else return false; } /** * Check if we are at the start of the resultset * @return boolean */ public function start() { return ($this->position < 0); } /** * Move to the next row of the resultset * @return boolean */ public function next() { return $this->goto($this->position+1); } /** * Move to the previous row in the resultset * @return boolean */ public function prev() { return $this->goto($this->position-1); } /** * Go to a specified row in the resultset * Row numbering starts at zero * @param int row * @return boolean */ public function goto($position) { if ($position < 0 || $position > $this->length) return false; else { $this->position = $position; return true; } } /** * Get the affected number of rows */ public function affectedRows() { return $this->affectedRows; } /** * Get the result resource itself */ public function &get() { return $this->result; } /** * Get the current position */ public function position() { return $this->position; } } // end of DB_Result ?> Quote Link to comment https://forums.phpfreaks.com/topic/204216-db-class-expecting-t_string-error/ Share on other sites More sharing options...
xcandiottix Posted June 8, 2010 Share Posted June 8, 2010 if ($position < 0 || $position > $this->length) return false; else { to if ($position < 0 || $position > $this->length) { return false; } else { Quote Link to comment https://forums.phpfreaks.com/topic/204216-db-class-expecting-t_string-error/#findComment-1069621 Share on other sites More sharing options...
nickelus Posted June 8, 2010 Author Share Posted June 8, 2010 thanx xcandiottix but that threw the same error. However I did get it, goto() appears to be a reserved function as of 5.3, as soon as i replace all instances with new name chgSpot() no error Quote Link to comment https://forums.phpfreaks.com/topic/204216-db-class-expecting-t_string-error/#findComment-1069627 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2010 Share Posted June 8, 2010 GOTO is a reserved keyword in the php version you are using. You need to change the name to something else. If you had read or posted the complete error message, it gives you a clue that the GOTO encountered in your code is part of the problem - Parse error: syntax error, unexpected T_GOTO, expecting T_STRING in your_file.php on line 142 Quote Link to comment https://forums.phpfreaks.com/topic/204216-db-class-expecting-t_string-error/#findComment-1069628 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.