Jump to content

Recommended Posts

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

?>

Link to comment
https://forums.phpfreaks.com/topic/204216-db-class-expecting-t_string-error/
Share on other sites

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.