Parse error: parse error, expecting `T_STRING' in C:\\HostingSpaces\\

Hi,

I am sending an email using php…and flagging up with the error

Parse error: parse error, expecting `T_STRING’ in C:\HostingSpaces\domain\mydomain.com\wwwroot\ est\plaincart\plaincart\controllers\contact_controller.class.php on line 4

Please see the code below and let me know where I mistook.


include("../library/config.php");
include("contact_controller.php");
class contact extends function 
{ 
	function add($post)
	{
	 $from = "Customer Care <info@mydomain.com>";
	 $to = "Admin <me@gmail.com>";
	 $subject = "Message from Customer";
	 $body = "Dear Admin,
	 
	 A customer ".$post['inpperson'].", has asked a quote, detials are:
	 Email: ".$post['inpemail']."Phone: ".$post['inphone']." Mobile: ".$post['inpmob']."State: ".$post['inpstate']."City: ".$post['txtothercity']."
	 
	 Message
	 
	 ".$post['message']."";
	 
	 $host = "mail.mydomain.com";
	 $username = "info@mydomain.com";
	 $password = "135446";
	 
	 $headers = array ('From' => $from,
	   'To' => $to,
	   'Subject' => $subject);
	 $smtp = Mail::factory('smtp',
	   array ('host' => $host,
		 'auth' => true,
		 'username' => $username,
		 'password' => $password));
	 
	 $mail = $smtp->send($to, $headers, $body);
	 $headers.="Content-type: text/html". "charset=iso-8859-1\\r\
";
	 
	 if (PEAR::isError($mail)) {
	   echo("<p>" . $mail->getMessage() . "</p>");
	  return false;
	  } else {
	   	return true;
	  }	
	}
	function getcity($state)
	{
		$sql="select * from tblcity where st_id =$state";
		$result = dbQuery($sql);
		return $result;
	}
}

Your help would be appreciated.


class contact extends function  
{  

Where you have the word “function”, you need to instead place the name of the class that is being extended.

For example:


class contact extends AppModel
{  

Or whichever class is more appropriate than “AppModel” to extend.

THanks pmw57,

I am newbie for php…

I’ve made class contact

and this is how I am calling it…


$contact = new contact; 

 $result = $contact->add($_POST);  

Please let me know if there is still something wrong.

What is the code library that you are trying to extend?

Ok…I copied this code from somewhere…

There is no library for functions…

now what to do with this…

how can I identify a class…and how to call it…

Thanks so much for your help.

Ahh, well that explains it.

The code you copied is guaranteed to NOT work without the rest of the stuff.

Consider it this way. The code that you copied is a custom knob for a gear-change lever, and you have an automatic car.

OK…that means…its not useful…

Well, thanks for your help…its much appreciated.

Thanks

$contact = new contact(); 

 $result = $contact->add($_POST);  

You were missing the () in the first line quoted above, inbetween the brackets would go any variables and/or objects that you intend to give that class via it’s constructor.