dont know how to get rid of syntax error, unexpected T_VARIABLE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashraf02
    New Member
    • Feb 2008
    • 53

    dont know how to get rid of syntax error, unexpected T_VARIABLE

    i have check the code thoroughly to find the error i am still getting the following error: Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Cat alogue.php on line 23
    [php]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <?php
    $conn = mysql_connect(" localhost","roo t","")
    or die (mysql_error()) ;
    mysql_select_db ("Shop_Test",$c onn) or die (mysql_error()) ;

    $display_block = "<h1>Categories </h1>
    <p>Select Category</p>";

    $get_cat = "SELECT Cat_ID, cat_title, cat_description FROM Store_Categorie s ORDER BY cat_title";
    $get_cat_result = mysql_query ($get_cat) or die (mysql_error()) ;

    if (mysql_num_rows ($get_cat_resul t) < 1) {
    $display_block = "<p><em>I'm sorry nothing to browse.</em></p>";
    } else {

    while ($cat = mysql_fetch_arr ay($get_cat_res ult)) {
    $Cat_ID = $cat[Cat_ID];
    $cat_title = strtoupper (stripslashes($ cat[cat_title]));
    $cat_desc = stripslashes ($cat[cat_description]);

    $display_block .= "<p><a
    href=\ "$_SERVER['PHP_SELF']?Cat_ID=$Cat_ID \">$cat_titl e</a><br>$cat_desc </p>";


    if ($_GET[Cat_ID] == $Cat_ID) {
    $get_items = "SELECT Store_ID, Item_title, Item_Price FROM
    Store_Items WHERE Cat_ID = $Cat_ID
    ORDER BY Item_Title";
    $get_item_resul ts = mysql_query ($get_items) or die (mysql_error()) ;

    if (mysql_num_rows ($get_item_resu lts) < 1 {
    $display_block = "<p><em>Sor ry No Items</em></p>";
    } else {

    $display_block .= "<ul>";

    while ($items = mysql_fetch_arr ay ($get_items_res ults)) {
    $item_id = $items [Store_ID];
    $item_title = stripslashes ($items[Item_Title]);
    $item_price = $items[Item_Price];

    $display_block .= "<li><a href=\ "showitem.php?i tem_id=$item_id \ ">$item_tit le</a>
    /</strong> (\$$item_price) ";
    }

    $display_block .= "<ul>";
    }
    }
    }
    }
    ?>[/php]
    sorry bout the layout. i have specified the part which says has an error
    really appreciate the help.

    To make it more clear enclose any code within the proper code tags. - moderator
    Last edited by ronverdonk; Feb 25 '08, 11:05 PM. Reason: code within appropriate tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Change it to:
    [php]
    $display_block .= "<p><a
    href=\
    "" . $_SERVER['PHP_SELF'] . "?Cat_ID=$Cat_I D\">$cat_titl e</a><br>$cat_desc </p>";
    [/php]
    Welcome to theScripts.

    Please remember to post code using the code tags, if you want to keep posting here.

    Comment

    • ashraf02
      New Member
      • Feb 2008
      • 53

      #3
      i have check the code thoroughly to find the error i am still getting the following error: Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Cat alogue.php on line 23

      [PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      <?php
      $conn = mysql_connect(" localhost","roo t","")
      or die (mysql_error()) ;
      mysql_select_db ("Shop_Test",$c onn) or die (mysql_error()) ;

      $display_block = "<h1>Categories </h1>
      <p>Select Category</p>";

      $get_cat = "SELECT Cat_ID, cat_title, cat_description FROM Store_Categorie s ORDER BY cat_title";
      $get_cat_result = mysql_query ($get_cat) or die (mysql_error()) ;

      if (mysql_num_rows ($get_cat_resul t) < 1) {
      $display_block = "<p><em>I'm sorry nothing to browse.</em></p>";
      } else {

      while ($cat = mysql_fetch_arr ay($get_cat_res ult)) {
      $Cat_ID = $cat[Cat_ID];
      $cat_title = strtoupper (stripslashes($ cat[cat_title]));
      $cat_desc = stripslashes ($cat[cat_description]);

      $display_block .= "<p><a
      href=\ "$_SERVER['PHP_SELF']?Cat_ID=$Cat_ID \">$cat_titl e</a><br>$cat_desc </p>";

      if ($_GET[Cat_ID] == $Cat_ID) {
      $get_items = "SELECT Store_ID, Item_title, Item_Price FROM
      Store_Items WHERE Cat_ID = $Cat_ID
      ORDER BY Item_Title";
      $get_item_resul ts = mysql_query ($get_items) or die (mysql_error()) ;

      if (mysql_num_rows ($get_item_resu lts) < 1 {
      $display_block = "<p><em>Sor ry No Items</em></p>";
      } else {

      $display_block .= "<ul>";

      while ($items = mysql_fetch_arr ay ($get_items_res ults)) {
      $item_id = $items [Store_ID];
      $item_title = stripslashes ($items[Item_Title]);
      $item_price = $items[Item_Price];

      $display_block .= "<li><a href=\ "showitem.php?i tem_id=$item_id \ ">$item_tit le</a>
      /</strong> (\$$item_price) ";
      }

      $display_block .= "<ul>";
      }
      }
      }
      }
      ?>[/PHP]

      Comment

      • ashraf02
        New Member
        • Feb 2008
        • 53

        #4
        Originally posted by markusn00b
        Change it to:
        [php]
        $display_block .= "<p><a
        href=\
        "" . $_SERVER['PHP_SELF'] . "?Cat_ID=$Cat_I D\">$cat_titl e</a><br>$cat_desc </p>";
        [/php]
        Welcome to theScripts.

        Please remember to post code using the code tags, if you want to keep posting here.
        Thanks alot mate i really appreciate it

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          One error is in 23
          [php]$display_block .= "<p><a href=\"{$_SERVE R['PHP_SELF']}?Cat_ID=$Cat_I D\">$cat_titl e</a><br>$cat_desc </p>";[/php]
          the other one is in stmt 31
          [php]if (mysql_num_rows ($get_item_resu lts) < 1) {[/php]
          another in stmt 41[php]$display_block .= "<li><a href=\"showitem .php?item_id=$i tem_id\">$item_ title</a>
          /</strong> (\$$item_price) ";[/php]Ronald

          Comment

          • ashraf02
            New Member
            • Feb 2008
            • 53

            #6
            Originally posted by ronverdonk
            One error is in 23
            [php]$display_block .= "<p><a href=\"{$_SERVE R['PHP_SELF']}?Cat_ID=$Cat_I D\">$cat_titl e</a><br>$cat_desc </p>";[/php]
            the other one is in stmt 31
            [php]if (mysql_num_rows ($get_item_resu lts) < 1) {[/php]
            another in stmt 41[php]$display_block .= "<li><a href=\"showitem .php?item_id=$i tem_id\">$item_ title</a>
            /</strong> (\$$item_price) ";[/php]Ronald
            Thanks alot roger i was gonna post another error but u already pointed it out. really appreciate it.

            Comment

            • ashraf02
              New Member
              • Feb 2008
              • 53

              #7
              Originally posted by ashraf02
              Thanks alot roger i was gonna post another error but u already pointed it out. really appreciate it.
              Ronver sorry !!!! not roger lol

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                It's okay. Glad to be of help. And see you again.

                Ronald

                Comment

                Working...