Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Script works locally but not online
Old 04-15-2010, 06:40 AM Script works locally but not online
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Can't get my head around this at all. It works fine when testing locally but won't work on my server! All it is is a basic form script:

PHP Code:
<?php

#######################################################################
// 
// 
// 
// 
#######################################################################

// send message via email and display results on contact page

if (($_POST['contactSend']) || ($_POST['quickSend'])) {
    
// set error variable for each field to use as errorCode
    // detect whether frm-quick was submitted
    
$error    = array ();
    if (
$_POST['quickSend']) {
        
$name     $_POST['quickName'];
        
$email    $_POST['quickEmail'];
        
$emailRep $_POST['quickEmailRep'];
        
$message  $_POST['quickMessage'];
    } else {
        
$name     $_POST['contactName'];
        
$email    $_POST['contactEmail'];
        
$emailRep $_POST['contactEmailRep'];
        
$message  $_POST['contactMessage'];
    }
    
    
// email headers
    
$subject  'Enquiry';
    
$mailEmail 'pealo86@gmail.com'// who will receive the email
    
$mailSender 'From: ' $name '<' $email '>'// who is sending the email
        
    // check valid and no null values in fields
    
if (!$name)    {
        
$error[] = 'name';
    }
    
    
// check email
    
if ((!preg_match ('#^[^@]+@([a-z0-9\-]+\.)+[a-z]{2,4}$#'$email) || ($email == NULL)))    {
        
$error[] = 'email';
    }
    
    
// check email matches only if email is valid
    
if (($errorEmail == 0) && ($email != $emailRep)) {
        
$error[] = 'emailRep';
    }
    
    
// check message exists
    
if (!$message)    {
        
$error[] = 'message';
    }
        
    
    
//default message
    
$errorCount count ($error);
    if (
$errorCount == 0)    {
        
$mailSend mail ($mailEmail$subject$message$mailSender);
        
        
// process error
        
if (!$mailSend) {
            
$error[] = 'server';
        } else {
            
// mail sent successfully
            
echo '
                <div id="frm-pop">
                <div>'
;
            echo 
'<p class="highlight">';
            echo 
"Thankyou for your enquiry. We'll get back to you as soon as possible.</p>
                </div>
                </div>"
;
        }
    } else {        
        
// echo error message if unsuccessul
        // declare warnings
        
$warning = array ('name'      => 'You did not enter your name',
                          
'email'     => 'You must enter a valid email address',
                          
'emailRep'  => 'Your two entered email addresses do not match',
                          
'message'   => 'You did not enter a message',
                          
'server'    => 'There was a problem processing your message. Please try again');
        echo 
'
            <div id="frm-pop">
            <div>
            <p class="highlight">Sorry but there '
;
            switch (
$errorCount) {
                case 
1:
                    echo 
'was ' $errorCount ' error ';
                    break;
                default:
                    echo 
'were ' $errorCount ' errors ';
              }
            
            echo 
' in your details. Please ' .
            
'review your entries.</p>
            <ul class="list bullet">'
;
            
        foreach (
$error as $value) {
            echo 
'<li>' $warning[$value] . '</li>';
          }
        
        echo 
'</ul>
            </div>
            </div>'
;
    }
}

?>
The script just cannot seem to put whatever is in the $_POST variables into another variable, such as this line:
PHP Code:
$name     $_POST['quickName']; 
If I echo '$name', nothing is output. But if I echo '$_POST['quickName'];' then the value appears on screen!

I've double checked to make sure that all of the fields are named correctly in my HTML document also.

I even cut out all of the code at the start so that it started with something like:

PHP Code:
$name     $_POST['quickName'];
$email    $_POST['quickEmail'];
$emailRep $_POST['quickEmailRep'];
$message  $_POST['quickMessage'];

echo 
$name
No luck again.

And even more confusing, I originally added these lines when trying to find the problem:
PHP Code:
    if ($_POST['quickSend']) {
        
$name     $_POST['quickName'];
        
$email    $_POST['quickEmail'];
        
$emailRep $_POST['quickEmailRep'];
        
$message  $_POST['quickMessage'];
        echo 
'1234';
        exit;
    } else { 
And it brings up this error:
Quote:
Parse error: syntax error, unexpected '}' in /home/inspin/public_html/freshbeat/concept/valleytheatre.co.uk/26032010/script/contact/process.php on line 85
And all that reads on line 85 is this:
PHP Code:
<class="highlight">Sorry but there '; 
!??!?!?!?!

Could it be the way my server is configured? As I say, the script works fine locally. What's even more confusing is the way I have very similar scripts running on my same hosting account with none of these issues!

Many thanks to anyone who can help.
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Reply     « Reply to Script works locally but not online
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33204 seconds with 12 queries