Results 1 to 12 of 12

Thread: Here's another Q....

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296

    Here's another Q....

    Parse error: parse error, unexpected T_INC in /home/djstop/public_html/test/phatfx.php on line 322

    my code:

    PHP Code:
    <?

            myconnect();


         $query = "SELECT * FROM `songs` ORDER BY `id` DESC";
         $result = mysql_query($query);
         $rows = @mysql_num_rows($result);

         $foundentries = false;

         while ($i < $rows) {
           $foundentries = true;

      $id = @mysql_result($result, $i, 'id');
      $title = @mysql_result($result, $i, 'title');
    ?>
    <option value="<?= $id?>"><?= $title?></option>
    <?

         i++;
    }
        myclose;
    ?>
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  2. #2
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    <option value="<?= $id; ?>"><?= $title; ?></option>

    whats with the "=$id" should just be $id, same for title

  3. #3
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by DJ P@CkMaN
    the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
    and also a very bad programming practice.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Here's another Q....

    Why don't you just do this?:

    PHP Code:
    <?php

      myconnect
    ();


      
    $query "SELECT * FROM `songs` ORDER BY `id` DESC";
      
    $result mysql_query($query);
      
    $rows = @mysql_num_rows($result);

      
    $foundentries false;

      while (
    $i $rows) {
          
    $foundentries true;

          
    $id = @mysql_result($result$i'id');
          
    $title = @mysql_result($result$i'title');

          echo 
    "<option value=\"$id\">$title</option>";

          
    i++;
      }
      
    myclose;
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    take the stupid ` off the column names and table

    and you should never use @ to surpress the errors until you know it will work without getting an error. see you have an error and you use the @ so how do you know where the error is being generated from? nothing towards you hobo I am just stating this in general.


    Carp: what line is 322? and try not to use mysql_result as it is a lot slower than mysql_fetch_array().

  7. #7
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    PHP Code:
    <?php

      myconnect
    ();

      
    $query "SELECT * FROM songs ORDER BY id DESC";
      
    $result mysql_query($query);    
    echo 
    "<form>";      
      while (
    $row mysql_fetch_array($result)) {
          
    $foundentries true;

    echo 
    "<option value=\"".$row["id"]."\">$row["title"]</option>";

      }
    echo 
    "</form>";
      
    myclose();
    ?>

  8. #8
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Originally posted by DJ P@CkMaN
    the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
    Learn something new everyday

  9. #9
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Originally posted by phpman
    PHP Code:
    <?php

      myconnect
    ();

      
    $query "SELECT * FROM songs ORDER BY id DESC";
      
    $result mysql_query($query);    
    echo 
    "<form>";      
      while (
    $row mysql_fetch_array($result)) {
          
    $foundentries true;

    echo 
    "<option value=\"".$row["id"]."\">$row["title"]</option>";

      }
    echo 
    "</form>";
      
    myclose();
    ?>
    PHP Code:
    <?php

      myconnect
    ();

      
    $query "SELECT * FROM songs ORDER BY id DESC";
      
    $result mysql_query($query);    
      echo 
    "<form>";      
      while (
    $row mysql_fetch_array($result)) {
          
    $foundentries true;

          echo 
    "<option value=\"".$row["id"]."\">".$row["title"]."</option>";

      }
      echo 
    "</form>";
      
    myclose();
    ?>
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    nothing towards you hobo I am just stating this in general.
    I didn't put them in there, I just copied his code. In fact, I didn't even realize they were in there.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296
    I fixed my error, All I had to do was put a $ before i++. I would have said this before but I couldn't connect to the server.
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    but our way you don't need to add the i variable and is more proficient.

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