ideahoppers Posted August 21, 2009 Share Posted August 21, 2009 I'm getting this error : Fatal error: Cannot re-assign $this in /home/i_up_size/iupsize.com/lib/pmsgs.php on line 18 Any help would be greatly appreciated! Here's the code: Class pmsgs { public $parentconvo; public $latest_msg; function pmsgs() { $this->parentconvo; $this->latest_msg; } function pconvoInsert($duedate, $budget) { $convoquery = "INSERT INTO pconvo (latest_msg, deadline, budget) VALUES ('0', '$duedate', '$budget')"; mysql_query($convoquery) or die(mysql_error()); $this1->parentconvo = mysql_insert_id(); return $this1->parentconvo; } function pmsgInsert($this1->parentconvo, $title, $bd, $to, $from) { $query = "INSERT INTO pmsg (parent_msg, parent_convo, date_sent, title, body, sent_to, sent_from) VALUES ('0', '$this ->pconvo', NOW(), '$title', '$bd', '$to', '$from')"; mysql_query($query) or die(mysql_error()); $this ->latest_msg = mysql_insert_id(); return $this ->latest_msg; } } Link to comment https://forums.phpfreaks.com/topic/171298-php-class-error-cannot-re-assign-this/ Share on other sites More sharing options...
ignace Posted August 21, 2009 Share Posted August 21, 2009 $this1 must be $this Link to comment https://forums.phpfreaks.com/topic/171298-php-class-error-cannot-re-assign-this/#findComment-903353 Share on other sites More sharing options...
ideahoppers Posted August 21, 2009 Author Share Posted August 21, 2009 Sorry I was testing it with $this1 - just to see if it would make a difference.. the original code is actually: Class pmsgs { public $parentconvo; public $latest_msg; function pmsgs() { $this->parentconvo; $this->latest_msg; } function pconvoInsert($duedate, $budget) { $convoquery = "INSERT INTO pconvo (latest_msg, deadline, budget) VALUES ('0', '$duedate', '$budget')"; mysql_query($convoquery) or die(mysql_error()); $this->parentconvo = mysql_insert_id(); return $this->parentconvo; } function pmsgInsert($this->parentconvo, $title, $bd, $to, $from) { $query = "INSERT INTO pmsg (parent_msg, parent_convo, date_sent, title, body, sent_to, sent_from) VALUES ('0', '$this ->pconvo', NOW(), '$title', '$bd', '$to', '$from')"; mysql_query($query) or die(mysql_error()); $this ->latest_msg = mysql_insert_id(); return $this ->latest_msg; } } Link to comment https://forums.phpfreaks.com/topic/171298-php-class-error-cannot-re-assign-this/#findComment-903360 Share on other sites More sharing options...
Daniel0 Posted August 21, 2009 Share Posted August 21, 2009 function pmsgInsert($this->parentconvo, $title, $bd, $to, $from) { Red part isn't allowed. You cannot do that. Link to comment https://forums.phpfreaks.com/topic/171298-php-class-error-cannot-re-assign-this/#findComment-903375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.