Results 1 to 4 of 4

Thread: Php Syntax help

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    2

    Question Php Syntax help

    Hi,

    I'm a newbie when it comes to PHP. I currently learning the language, but stuck with the following:-

    Parse error: syntax error, unexpected T_IF in /home/fhlinux192/e/eatlunch.co.uk/user/htdocs/library/register1.php on line 45

    Keep getting the above message, and the lines in my php refering to this is:-

    // Check Eat 1 details
    $vEat1 = $_POST['Eat1'];
    if (!empty(trim($vEat1))) { <-- this is line 45 in my script
    /* Not empty */
    $sSQL = "INSERT INTO webelorderdetails (SessionID, MSelect_Code, MSelect_Desc, MSelect_Qty) VALUES ('$sid', 'WM0001-000000', 'Eat 1', '$BuffetDate')";

    $result = mysql_query($sSQL, $conn);
    }

    I don’t know what the correct syntax should be, any helpful pointers.

    Regards

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Php Syntax help

    there is nothing wrong with your syntax. however, there is something wrong with your use of empty(). empty() is a function that checks if a variable is either true or false, and will not check whether a function call is true or false. this is in the documentation for empty().

    if you change your code slightly, you will be fine:
    PHP Code:
    // Check Eat 1 details
    $vEat1 trim($_POST['Eat1']);
    if (!empty(
    $vEat1)) { 
    also, in the future you might want to use [php] and [/php] tags to display your code. it's much easier to read.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    2

    Re: Php Syntax help

    Hi kows,

    Thanks you for the prompt reply, I will updae my script and post any furthr developments.

    Thanks

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Php Syntax help

    And ensure that you read what the manual says before you copy and paste code from it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width