milnet Posted May 18, 2009 Share Posted May 18, 2009 I have a class that reads an xml file with simplexml and it tries to get a $_POST variable based off a value in the xml file. It keeps giving me warning "Illegal offset type." I have tried multiple things to fix it but I just can't figure it out. Any help would be greatly appreciated. function submitform(){ if($this->xml->formprocess->contact){ echo $this->xml->formprocess->contact->firstname; echo $_POST[$this->xml->formprocess->contact->firstname]; } } Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 18, 2009 Share Posted May 18, 2009 can you post all of the code, it may help us figure out the problem. Quote Link to comment Share on other sites More sharing options...
milnet Posted May 19, 2009 Author Share Posted May 19, 2009 Yeah here is some more. Sorry. class xmlform { var $mainid; var $contentid; var $formlabel; var $formdesc; var $inputstring; var $xml; function __construct($xmlfile){ if(file_exists($xmlfile)){ $this->xml = new SimpleXMLElement($xmlfile, NULL, TRUE); } else { die('xml fail'); } if(!$_POST['submit']){ $this->makeform(); include("forms/formtemp.php"); } else{ $this->submitform(); //include("forms/formthankyou.php"); } } function makeform(){... ... } function submitform(){ $cw = new contactwisesession(); if($this->xml->formprocess->contact){ echo $this->xml->formprocess->contact->firstname; echo $_POST[$this->xml->formprocess->contact->firstname]; } } } This is the line that is giving me trouble: echo $_POST[$this->xml->formprocess->contact->firstname]; Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 19, 2009 Share Posted May 19, 2009 please use code tags next time... try: if($this->xml->formprocess->contact){ echo $this->xml->formprocess->contact->firstname; $firstname = (string)$this->xml->formprocess->contact->firstname; echo $_POST[$firstname]; } Quote Link to comment Share on other sites More sharing options...
milnet Posted May 19, 2009 Author Share Posted May 19, 2009 That worked great. Thank you very much! Quote Link to comment 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.