SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Parse Error

  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse Error

    Im getting a nasty parse error on my code

    PHP Code:
    if ($_POST['Submit'] == TRUE)
    {
        $FixedPrice = '99';
        $ProductName = $_POST['ProductName'];
        $Finish = $_POST['Finish'];
        $Size = $_POST['Size'];
        $Price = $_POST['Price'];
        $Quantity = $_POST['Quantity'];
        
        $Connect = mysql_connect('localhost', 'glenn', '********') or die(myql_error);
        
        mysql_select_db('shadesofjapan', $Connect);

    //The line below is the error line

        $Result = mysql_query("INSERT INTO shoppinglist (ProductName, Finish, Size, Price, Quantity, UserId) VALUES ('$ProductName', '$Finish', '$Size', '$Price', '$Quantity', '$_SESSION['UserId']')");
        
        if ($Result == TRUE)
        {
            ?>
            <script type="text/javascript">
            alert("Item added to shopping list")
            </script>
            <?
        
    }
        
        else
        {    
            
    ?>
            <script type="text/javascript">
            alert("Failed!")
            </script>
            <?
        
    }


    }

    ?>
    I know its something to do with the session variable being in there but im not sure hopw to correct it.

    Thanks in advance
    Last edited by webnoob; Apr 28, 2005 at 11:20. Reason: To remove my password
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You have to enclose the session variable with curly brackets:

    PHP Code:
    $Result mysql_query("INSERT INTO shoppinglist (ProductName, Finish, Size, Price, Quantity, UserId) VALUES ('$ProductName', '$Finish', '$Size', '$Price', '$Quantity', '{$_SESSION['UserId']}')"); 
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    worked a treat, thanks
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"


Bookmarks

Posting Permissions

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