SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast tipiyanos's Avatar
    Join Date
    Jun 2001
    Location
    NY, New York
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need someone to trouble shoot this script error

    Hi

    I am making the administration area for a product catalog. To add a product a person will select a category fro a list which will be pulled from the database. However, there is something going wrong which i am not able to understand. Any help would be appreciated. Heres the relevant part of the code.
    PHP Code:
    <?
    $title
    =Add Prdocut;
    include(
    "../connect.inc");
    include(
    "templates/header.inc"); ?>

    <?
    function build_category_tree(&$output$parent=0$indent=""
    {

        
    $qid mysql_query("SELECT id, name FROM categories WHERE parent_id = $parent");
        while (
    $cat =  mysql_fetch_array($qid)) {
            
    $output .= "<option value='$cat["id"]'>$indent$cat["name"];
            if (
    $cat["id"] != $parent) {
                
    build_category_tree($output$cat["id"], $indent."&nbsp;&nbsp;");
            }
        }
    }
    ?>

    Category
    Category: <SELECT NAME="sizeid" SIZE=1>
      <OPTION SELECTED VALUE="" >Select Category
      <OPTION VALUE="">---------
    <?php
    $output
    ="";
    build_category_tree($output);
    echo(
    $output);

    <? include(
    "templates/footer.inc"?>
    the header and the footer just contain the html formatting and the connect.inc has the information to connect to the database.

    Heres the error I am getting from the browser on running the script.

    Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\apache\htdocs\surplusgemstones\admin\test.php on line 12

    I have no idea what that means.
    Thanks for the help in advance.

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's because you have $cat["id"] inside of your .= "...". You can do $cat[id] or concat it into the string like you did for $cat["name"].

  3. #3
    SitePoint Enthusiast tipiyanos's Avatar
    Join Date
    Jun 2001
    Location
    NY, New York
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for pointing that out. But still there is some error in the code. Now the browser is pointing the error to line 29 which is where I am calling the function.

    I am sure it is something basic but I am new to php.

    Thanks for the help.

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take out the <? before you include the footer.

  5. #5
    SitePoint Enthusiast tipiyanos's Avatar
    Join Date
    Jun 2001
    Location
    NY, New York
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I knew it was something very basic. how did i miss that.

    thanks for the help buddy. It is working fine now.


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
  •