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 9 of 9

Thread: unexpected ;

  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts

    unexpected ;

    Code:
    Parse error: parse error, unexpected ';' in C:\Program Files\xampp\xampp\xampp\htdocs\ctut\added.php on line 49
    is the error
    PHP Code:
    <?php 
    include 'mysql_connect.php';
    $errors = array("You haven't entered a title or the tutorial""You haven't entered a valid link for the tutorial""You haven't entered you name");
    $error ''
    if (!isset(
    $_POST['title'])) {
    $error $errors[0];
    }

    if (!isset(
    $_POST['link'])) {
    $error .= $errors[1]; //this line is giving error
    }

    if (!isset(
    $_POST['author'] {
    $error .= $errors[2];
    }
    if (
    $error != '') {
    die(
    $error);
    }else{
    $i $_POST['catid']
    switch (
    $i) {
    case 
    "HTML":
        
    $cat_id 1;
        break;
    case 
    "CSS":
        
    $cat_id 2;
        break;
    case 
    "Javascript":
        
    $cat_id 3;
        break;
    case 
    "PHP":
        
    $cat_id 4;
        break:
    case 
    "MYSQL" :
        
    $cat_id 4;
        break:
    case 
    "Photoshop" :
        
    $cat_id 5
        
    break:
    case 
    "Flash" :
        
    $cat_id 6;
        break:
        }
    is some of the PHP code
    Last edited by rafiki; 04-02-2007 at 06:25 PM. Reason: found new error

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Missing closing brackets
    PHP Code:
    if (!isset($_POST['author'])) { 
    You're missing loads of semi-colons
    PHP Code:
    $i $_POST['catid'];
    switch (
    $i) {
    case 
    "HTML":
        
    $cat_id 1;
        break;
    case 
    "CSS":
        
    $cat_id 2;
        break;
    case 
    "Javascript":
        
    $cat_id 3;
        break;
    case 
    "PHP":
        
    $cat_id 4;
        break;
    case 
    "MYSQL" :
        
    $cat_id 4;
        break;
    case 
    "Photoshop" :
        
    $cat_id 5;
        break;
    case 
    "Flash" :
        
    $cat_id 6;
        break;
        } 

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    tyvm i havent had much sleep and surviving on coffee alone pos rep added
    or not it wont let me because your the last user i gave it too
    Last edited by rafiki; 04-02-2007 at 06:35 PM.

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You were missing lots of semicolons and parenthesis
    Here is the code after Correction
    PHP Code:
    <?php 
    include 'mysql_connect.php';
    $errors = array("You haven't entered a title or the tutorial""You haven't entered a valid link for the tutorial""You haven't entered you name");
    $error ''
    if (!isset(
    $_POST['title'])) {
    $error $errors[0];
    }

    if (!isset(
    $_POST['link'])) {
    $error .= $errors[1]; //this line is giving error
    }

    if (!isset(
    $_POST['author']))
        {
            
    $error .= $errors[2];
        }
    if (
    $error != '')
        {
            die(
    $error);
        }
    else
    {
    $i $_POST['catid'];
    switch (
    $i) {
    case 
    "HTML":
        
    $cat_id 1;
        break;
    case 
    "CSS":
        
    $cat_id 2;
        break;
    case 
    "Javascript":
        
    $cat_id 3;
        break;
    case 
    "PHP":
        
    $cat_id 4;
        break;
    case 
    "MYSQL" :
        
    $cat_id 4;
        break;
    case 
    "Photoshop" :
        
    $cat_id 5;
        break;
    case 
    "Flash" :
        
    $cat_id 6;
        break;
        }
    }
    Add a default case

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    that page is working correctly now
    this is my new error
    Code:
    Parse error: parse error, unexpected $end in C:\Program Files\xampp\xampp\xampp\htdocs\staceyfenton\contact.php on line 119

    PHP Code:
    <?php 
    if ($_GET['action'] == send)
    {
    $to "naughtydevilstacey@hotmail.co.uk";
    $subject "Modelling";
    $message $_POST['message'];
    $message .= $_POST['from'];
    if(
    md5($_POST['code']) != $_SESSION['key'])
    {
      die(
    "Error: You must enter the code correctly"); //code for incorrect input
    }else{
    $mail mail($to$subject$message);
    if (
    $mail) {
    echo 
    "mail sent please await a reply";
    }else{
    echo 
    "error sending mail please try later";
    }
    }
    }else{
    echo 
    '<form action="contact.php?action=send" method="post">';
    echo 
    '<input type="text" name="from" value=""/>';
    echo 
    '<textarea rows=10 cols=60>Enter you message here</textarea">';
    include
    'captcha.php';
    echo 
    "<input type=text name=code /> Enter the code you see in the image";
    ?>
    thats all the php apart from at the very top of the page i have
    session_start()

    page 119 is the last line of my whole file
    as you may have guessed
    Code:
    </body></html>

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Your missing your last }

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    No closing curly bracket
    PHP Code:
    }else{
    echo 
    '<form action="contact.php?action=send" method="post">';
    echo 
    '<input type="text" name="from" value=""/>';
    echo 
    '<textarea rows=10 cols=60>Enter you message here</textarea">';
    include
    'captcha.php';
    echo 
    "<input type=text name=code /> Enter the code you see in the image";
    }
    ?> 
    Read the error and look through your code, you're making silly mistakes that shouldn't happen if you took your time

  • #8
    New to the CF scene
    Join Date
    Oct 2006
    Location
    India
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ya Last } of Else
    Did you added the default case ??

  • #9
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    ty again
    no the default case is photoshop


  •  

    Posting Permissions

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