Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    unexpected T_ECHO

    it is a php script wchich i want to put on my website but it showes an unexpected T_ECHO on line 6. Thats the code
    Code:
    <?php
    
    
    if (
    	(!empty($_POST['name'])) or (!empty($_POST['email'])) or (!empty($_POST['title'])) 
       echo"fill in all fields"; 
    )
    
     
    else (
      mail ('kontakt@mywebsite.com', '$title', '$text')
      echo"it was send correctly, go back on <a href=\"http://www.mywebsite.com\">main page</a><br />
      or to <a href=\"http://www.mywebsite.com\">cobntact formular</a>";	
    )
    
    ?>
    Ps sorry for my english
    Last edited by Adbem; 01-31-2010 at 12:52 PM.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    There is no need to echo function parameters.

    And no need to nest [php] tags within [code] tags when displaying PHP code.

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok but can you help me because i tried everything and i have no idea what is wrong

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Code:
    <?php
    
    
    if (!empty($_POST['name'])||!empty($_POST['email'])||!empty($_POST['title'])){ 
       echo"fill in all fields"; 
    }else {
      mail ('kontakt@mywebsite.com', '$title', '$text');
      echo"it was send correctly, go back on <a href=\"http://www.mywebsite.com\">main page</a><br />
      or to <a href=\"http://www.mywebsite.com\">cobntact formular</a>";	
    }
    
    ?>
    try
    flying dagger

  • #5
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Ah, your code wasn't very readable, and without the semicolon it appeared that you were echoing a parameter.

  • #6
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Trying giving some whitespace for a cleaner code.

    PHP Code:
    <?php


    if (!empty($_POST['name']) || !empty($_POST['email']) || !empty($_POST['title'])) { 
       echo 
    'fill in all fields'
    }
    else {
      
    mail ('kontakt@mywebsite.com''$title''$text');
      echo
    "it was send correctly, go back on <a href=\"http://www.mywebsite.com\">main page</a><br />
      or to <a href=\"http://www.mywebsite.com\">cobntact formular</a>"
    ;    
    }

    ?>
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #7
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    You have mismatched parentheses:

    This:
    Code:
    if (!empty($_POST['name'])||!empty($_POST['email'])||!empty($_POST['title'])){
    should be
    Code:
    if ((!empty($_POST['name'])||!empty($_POST['email'])||!empty($_POST['title'])){
    John


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •