Jump to content

Flaperdubbers!


Millar

Recommended Posts

:'(, I have written a script, also I haven'e configured the MySQL to work yet so I know it wont. The problem I have is, on the area - var $name = $this->data(name); - I get a parse error, Parse error: parse error, unexpected T_VARIABLE. When I put that variable in quotes I get this error, Parse error: parse error, unexpected '\"'.Here is the code I'm using.

<?//------------------------------------------------------// Require MySQL...//------------------------------------------------------require_once("MySQL.php");$sesID = $_COOKIE['xM_ID'];class user {	function data ( $rowinfo ) {	  $rowinfo = "'$rowinfo'";	  $query = "SELECT * FROM xM_members WHERE id = '$sesID'";  $result = mysql_query( $this->query );  $row = mysql_fetch_array( $this->result );    $return = "$row[$rowinfo]";    return $return;		}	  //var $query = "SELECT * FROM xM_members WHERE id = ";  //var $result = mysql_query( $this->query );  //var $row = mysql_fetch_array( $this->result );		var $name = "$this->data(name)";}$user = new user;print "Logged in as: $user->name";print "$sesID";?>

Link to comment
Share on other sites

Try putting name in quotes. You don't need all the quotes around everything else though.

<?//------------------------------------------------------// Require MySQL...//------------------------------------------------------require_once("MySQL.php");$sesID = $_COOKIE['xM_ID'];class user {function data ( $rowinfo ) { $rowinfo = "'$rowinfo'"; $query = "SELECT * FROM xM_members WHERE id = '$sesID'"; $result = mysql_query( $this->query ); $row = mysql_fetch_array( $this->result );  $return = $row[$rowinfo];  return $return;} //var $query = "SELECT * FROM xM_members WHERE id = "; //var $result = mysql_query( $this->query ); //var $row = mysql_fetch_array( $this->result );var $name = $this->data("name");}$user = new user;print "Logged in as: {$user->name}";print $sesID;?>

Link to comment
Share on other sites

Try putting name in quotes.  You don't need all the quotes around everything else though.
<?//------------------------------------------------------// Require MySQL...//------------------------------------------------------require_once("MySQL.php");$sesID = $_COOKIE['xM_ID'];class user {function data ( $rowinfo ) { $rowinfo = "'$rowinfo'"; $query = "SELECT * FROM xM_members WHERE id = '$sesID'"; $result = mysql_query( $this->query ); $row = mysql_fetch_array( $this->result );  $return = $row[$rowinfo];  return $return;} //var $query = "SELECT * FROM xM_members WHERE id = "; //var $result = mysql_query( $this->query ); //var $row = mysql_fetch_array( $this->result );var $name = $this->data("name");}$user = new user;print "Logged in as: {$user->name}";print $sesID;?>

Didn't work :'(....
Link to comment
Share on other sites

I'm thinking it's because there is that line of executable code in the class definition. I believe that the class definition only declares everything, it declares functions (methods) and variables (properties). If you want to declare and initialize a variable, you can only initialize it to a constant value, not through a function call. If he wants something to execute when the class gets instantiated, then that should go in the constructor.

class user {  function user ()  {    $this->name = $this->data("name");  }  function data ( $rowinfo )   {    $rowinfo = "'$rowinfo'";    $query = "SELECT * FROM xM_members WHERE id = '$sesID'";    $result = mysql_query( $this->query );    $row = mysql_fetch_array( $this->result );    return $row[$rowinfo];  }}

Edit: I'm pretty sure you want to use mysql_fetch_assoc instead of mysql_fetch_array, $rowinfo is a string, not a number

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...