GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Feb-2009, 13:43
swaves swaves is offline
New Member
 
Join Date: Feb 2009
Posts: 4
swaves is on a distinguished road

Parse error in PhP


This is new to me, but I am trying to make the "send mail" function work on my flash page. Any help would be greatly appriciated, I have been working on this for 3 days now
Here is the info:

ERROR MESSAGE:
Warning: main(Mail.php): failed to open stream: No such file or directory in /u34/swaves/email tutorial/php/sendtofriend.php on line 4

Fatal error: main(): Failed opening required 'Mail.php' (include_path='.:/usr/local/php/include') in /u34/swaves/email tutorial/php/sendtofriend.php on line 4

RELATED DOCUMENTS
SENDFRIEND.PHP -
PHP Code:

<?php

include("config.php"); 
require_once "Mail.php";

$job=$_REQUEST["job"];

if($job=="sendtofriend")
{
    $yname=$_REQUEST["yname"];
    $yemail=$_REQUEST["yemail"];
    $fname=$_REQUEST["fname"];
    $femail=$_REQUEST["femail"];
    $message=$_REQUEST["Message"];
    $url=$_REQUEST["Url"];
    
    
    $msg="Your friend <b>".$yname."</b> (".$yemail.") sent you this article!<br>";
    $msg.="<br><br><a href=".$url."> Click here to view article</a>";
    $msg.="<br><br>".$url;
    $msg.="<br><br>Your friend's message:<br><br>".$message;
    
    $subject=$yname." sent you an article!";
    
    //echo SendEmail($GLOBALS['fromName']."<".$GLOBALS['fromEmail'].">",$femail,$subject,$msg); 
    echo SendEmail($femail,$subject,$msg);

} else {
    echo("action=error occured");
}

?>


MAIL.PHP -
PHP Code:

<?php
define("_MAIL_MSGBODY", "Message body is not set.");
define("_MAIL_FAILOPTPL", "Failed opening template file.");
define("_MAIL_FNAMENG", "From Name is not set.");
define("_MAIL_FEMAILNG", "From Email is not set.");
define("_MAIL_SENDMAILNG", "Could not send mail to %s.");
define("_MAIL_MAILGOOD", "Mail sent to %s.");
define("_MAIL_SENDPMNG", "Could not send private message to %s.");
define("_MAIL_PMGOOD", "Private message sent to %s.");
?>


CONFIG.PHP - personal data *** out
PHP Code:

<?php


#Change the value of the following variables according to your configuration

 $smtphost = "smtp.****";          #SMTP Server name/IP
 $smtpport = 25;                            #Change to your SMTP server port if not 25
 $username = "***@****.com";          #SMTP UserName
 $password = "****";          #SMTP Password
 $fromName = "****";                    #A default name value to indicate where the email is from
$fromEmail = "****";  #A default email value to indicate where the email is from


function SendEmail ($strFrom,$strTo,$strSubject,$strMailBody){
    $headers = array ('From' => $strFrom,
                      'To' => $strTo,
                      'Content-Type' => "text/html; charset=ISO-8859-1",
                      'Subject' => $strSubject);
  
    $smtp = Mail::factory('smtp',
                          array ('host'     => $GLOBALS['smtphost'],
                                   'auth'     => true,
                                   'port'     => $GLOBALS['smtpport'],
                                   'username' => $GLOBALS['username'],
                                   'password' => $GLOBALS['password']));
        
    $mail = $smtp->send($strTo, $headers, $strMailBody);
    
    if (PEAR::isError($mail)) {
        return "action=error occured";
        //return $mail->getMessage();
     } else {
         return "action=sent";
     }
}
?>

Last edited by swaves : 04-Feb-2009 at 14:00. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 04-Feb-2009, 14:39
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,141
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error in PhP


That is not a parse error...

What is the full path to the 'Mail.php' file?

If it is not [based on the 'include_path' in the fatal error message] in the same directory (the dot) where sendfriend.php is located, or in /usr/local/php/include, then PHP can't locate the file.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 04-Feb-2009, 14:52
swaves swaves is offline
New Member
 
Join Date: Feb 2009
Posts: 4
swaves is on a distinguished road

Re: Parse error in PhP


Thanks for the reply.
My host server told me to have it in my "cgi-bin" folder .
So how should the line read? Noob to all this and just trying to get it to work.
Thanks again
  #4  
Old 04-Feb-2009, 18:35
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,141
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error in PhP


I'm not sure why they would want it there...is it something they reference too?

Why not, just for temporary testing sake, copy the file to your php directory and see how it goes?

If that works ok, then there are two possibilities:
1. keep the file there, where specifically needed

or (if it'll be needed by multiple scripts)

2. append another path (the cgi-bin path) to the 'include_path' using ini_set(). Be careful that you concatenate the additional path [including a path-separator, the colon], and not replace what's there now.
At the top of the script, the ini_set() would be used like this:
PHP Code:

ini_set('include_path', ini_get('include_path') . ':/path/to/your/cgi-bin'); 



EDIT:
Oh, lest I forget: ini_set() only temporarily modifies the 'include_path' for the current script. So this method will be needed whenever you need a path included. Since you don't have control of php.ini, it won't be permanent.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #5  
Old 04-Feb-2009, 18:49
swaves swaves is offline
New Member
 
Join Date: Feb 2009
Posts: 4
swaves is on a distinguished road

Re: Parse error in PhP


Turns out it was just case sensitive...mail.php not Mail.php
But now i get this error. Note the config.php from previous post.

Warning: main(Mail.php): failed to open stream: No such file or directory in
/u34/swaves/email tutorial/php/sendtofriend.php on line 4

Fatal error: main(): Failed opening required 'Mail.php'
(include_path='.:/usr/local/php/include') in /u34/swaves/email
tutorial/php/sendtofriend.php on line 4
  #6  
Old 04-Feb-2009, 18:55
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,141
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error in PhP


I don't see what that has to do with the config file?

Those appear to be the exact same messages from before, so what has changed? I still see [M]ail.php in the error, and the complaint [still] mentions the sendtofriend.php file.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #7  
Old 04-Feb-2009, 21:12
swaves swaves is offline
New Member
 
Join Date: Feb 2009
Posts: 4
swaves is on a distinguished road

Re: Parse error in PhP


Sorry my error. Been trying to figure this out too long. I copied the old error.
This is the error message

Warning: Missing argument 4 for sendemail() in /u34/swaves/email tutorial/php/config.php on line 14

Fatal error: Undefined class name 'mail' in /u34/swaves/email tutorial/php/config.php on line 20
  #8  
Old 05-Feb-2009, 13:59
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,141
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error in PhP


1. Ok, so think about what the warning is telling you...

What is different between the definition of SendEmail() in the config vs. how it is called from the sendtofriend.php file?

2. The error appears to be at this line:
PHP Code:

if (PEAR::isError($mail)) { 


The $mail result from smtp's send() call must be a non-object, like a true or false result. So passing $mail to isError() is not what is needed. Maybe the $smtp object could be used instead? Or is there a Mail::isError() instead of PEAR?

Or if the send() does return true, or false, [as to the success of send()] then change the condition. Maybe something like this:
PHP Code:

// You'll need verify what send returns with failure. (this is only an example)    if ( $mail == false) { 


__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by TurboPT : 05-Feb-2009 at 14:45.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, unexpected T_STRING in /home/content/R/i/c/RichardAKnox/htm Richardknox MySQL / PHP Forum 5 18-Nov-2006 22:20
parse .html as php petenyce405 Apache Web Server Forum 1 05-Aug-2005 07:21
Help ! I need help starting up on Php ! onauc MySQL / PHP Forum 11 05-Jan-2005 00:57
PHP in HTML jrobbio Web Design Forum 4 24-Jul-2003 07:05
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 17:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:46.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.