php question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    php question

    I am new to php and am working on a script to show search results. I am getting the following error with this and was wondering if I am doing something wrong or have the wrong version of php on my server because I am copying this code directly from php5 and mysql4 for dummies and have php4 on my server:

    <?php

    $user = "user";
    $host = "localhost";
    $password = "pass";
    $database = "database";

    $connection = mysql_connect($host,$user,$password)
    or die ("Couldn't connect to server");
    $db = mysql_select_db($database,$connection)
    or die ("Couldn't select database");

    $query = "SELECT * FROM `features`";
    $result = mysql_query($query)
    or die ("Couldn't execute query.");

    /* Dsiplay results in a table */

    echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?";
    echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n;

    while ($row = mysql_fetch_array{result,MYSQL_ASSOC))
    {

    /* display row for each listingid */
    echo "<tr>\n;
    echo "<td>{$row['intersection1']}</td>\n";
    ?>



    I get his error:


    Parse error: parse error, unexpected '>' in /public_html/pa/index.php on line 26
  • arnette
    Confirmed User
    • Feb 2005
    • 283

    #2
    you need a " at the end of your echo

    Comment

    • arnette
      Confirmed User
      • Feb 2005
      • 283

      #3
      twice

      ...

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47880

        #4
        change this:
        echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n;

        to:
        echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n";

        in case it wasn't obvious what arnette said...
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • arnette
          Confirmed User
          • Feb 2005
          • 283

          #5
          Originally posted by woj
          change this:
          echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n;

          to:
          echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n";

          in case it wasn't obvious what arnette said...
          this one too

          echo "<tr>\n;

          to:
          echo "<tr>\n";

          Comment

          • V_RocKs
            Damn Right I Kiss Ass!
            • Nov 2003
            • 32466

            #6
            No you didn't close the loop with a }

            Comment

            • V_RocKs
              Damn Right I Kiss Ass!
              • Nov 2003
              • 32466

              #7
              Also, this is better written from,
              Code:
              echo "<td>{$row['intersection1']}</td>\n";
              to
              Code:
              echo "<td>".$row['intersection1']."</td>\n";
              And when you post code here, use code tags or we might not see what you typed.

              Comment

              • Alky
                Confirmed User
                • Apr 2002
                • 5651

                #8
                Originally posted by V_RocKs
                Also, this is better written from,
                Code:
                echo "<td>{$row['intersection1']}</td>\n";
                to
                Code:
                echo "<td>".$row['intersection1']."</td>\n";
                And when you post code here, use code tags or we might not see what you typed.
                you edit fast, i was about to call you on your error

                Comment

                • mkx
                  Confirmed User
                  • Nov 2003
                  • 4001

                  #9
                  Still shows same error after changing to:

                  /* display row for each listingid */
                  echo "<tr>\n";
                  echo "<td>{$row['intersection1']}</td>\n";
                  ?>

                  Comment

                  • Alky
                    Confirmed User
                    • Apr 2002
                    • 5651

                    #10
                    Originally posted by raulph
                    Still shows same error after changing to:

                    /* display row for each listingid */
                    echo "<tr>\n";
                    echo "<td>{$row['intersection1']}</td>\n";
                    ?>
                    you need to close your while loop

                    put a } before the ?>

                    Comment

                    • Alky
                      Confirmed User
                      • Apr 2002
                      • 5651

                      #11
                      also
                      while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) is wrong,

                      it should be
                      while ($row = mysql_fetch_array($result,MYSQL_ASSOC))

                      Comment

                      • mkx
                        Confirmed User
                        • Nov 2003
                        • 4001

                        #12
                        Ok changed to:

                        Code:
                        /* Dsiplay results in a table */
                        
                        echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?";
                        echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n";
                        
                        while ($row = mysql_fetch_array{result,MYSQL_ASSOC))
                        
                        
                        /* display row for each listingid */
                        echo "<tr>\n";
                        echo "<td>".$row['intersection1']."</td>\n";
                        ?>
                        Now I get this error:


                        Parse error: parse error, unexpected '{' in /public_html/pa/index.php on line 22

                        Comment

                        • Alky
                          Confirmed User
                          • Apr 2002
                          • 5651

                          #13
                          you didnt copy this code very well...

                          Comment

                          • mkx
                            Confirmed User
                            • Nov 2003
                            • 4001

                            #14
                            Originally posted by Alky
                            also
                            while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) is wrong,

                            it should be
                            while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
                            problem solved. Thanks!

                            Comment

                            • Zester
                              Confirmed User
                              • Jul 2003
                              • 5344

                              #15
                              found a few too:
                              Code:
                              echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?";
                              look at the "border" part, its missing a '
                              also the "?" at the end of it should be a ">" instead

                              e.g:
                              Code:
                              echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";
                              * Mainstream ? $65 per sale
                              * new male contraception

                              Comment

                              • V_RocKs
                                Damn Right I Kiss Ass!
                                • Nov 2003
                                • 32466

                                #16
                                Did you END the loop?

                                Code:
                                while ($row = mysql_fetch_array{result,MYSQL_ASSOC))
                                {
                                
                                /* display row for each listingid */
                                echo "<tr>\n;
                                echo "<td>{$row['intersection1']}</td>\n";
                                }
                                Notice the }

                                Comment

                                • Alky
                                  Confirmed User
                                  • Apr 2002
                                  • 5651

                                  #17
                                  man your screwing it all up ... now you need a { after your while statement

                                  Comment

                                  • mkx
                                    Confirmed User
                                    • Nov 2003
                                    • 4001

                                    #18
                                    Originally posted by Alky
                                    you didnt copy this code very well...
                                    Nope, for a second there I thought php for dummies was for dummies but now I realize I am the dummy. Thanks for everyones help

                                    Comment

                                    • Zester
                                      Confirmed User
                                      • Jul 2003
                                      • 5344

                                      #19
                                      wow you guys are fast posters
                                      * Mainstream ? $65 per sale
                                      * new male contraception

                                      Comment

                                      • Alky
                                        Confirmed User
                                        • Apr 2002
                                        • 5651

                                        #20
                                        Originally posted by Zester
                                        e.g:
                                        Code:
                                        echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";
                                        html with ' is ugly

                                        Comment

                                        • mkx
                                          Confirmed User
                                          • Nov 2003
                                          • 4001

                                          #21
                                          Added the loop, Even better, Thanks!

                                          Comment

                                          • V_RocKs
                                            Damn Right I Kiss Ass!
                                            • Nov 2003
                                            • 32466

                                            #22
                                            Not to mention, mysql_assoc_array($result)
                                            would work for that section too.

                                            Comment

                                            • V_RocKs
                                              Damn Right I Kiss Ass!
                                              • Nov 2003
                                              • 32466

                                              #23
                                              Originally posted by Alky
                                              man your screwing it all up ... now you need a { after your while statement
                                              haha.. touche... }

                                              Comment

                                              • mkx
                                                Confirmed User
                                                • Nov 2003
                                                • 4001

                                                #24
                                                One more quicky, how do I make it display Intersection1 & Intersection2 such as "Street1 & Street2" in the line :

                                                echo "<td>".$row['intersection1']."</td>\n";

                                                Comment

                                                • Alky
                                                  Confirmed User
                                                  • Apr 2002
                                                  • 5651

                                                  #25
                                                  Originally posted by raulph
                                                  Ok changed to:

                                                  Code:
                                                  /* Dsiplay results in a table */
                                                  
                                                  echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?";
                                                  echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n";
                                                  
                                                  while ($row = mysql_fetch_array{result,MYSQL_ASSOC))
                                                  
                                                  
                                                  /* display row for each listingid */
                                                  echo "<tr>\n";
                                                  echo "<td>".$row['intersection1']."</td>\n";
                                                  ?>
                                                  Originally posted by V_RocKs
                                                  haha.. touche... }
                                                  i was going from that ;)

                                                  Comment

                                                  • Alky
                                                    Confirmed User
                                                    • Apr 2002
                                                    • 5651

                                                    #26
                                                    Originally posted by raulph
                                                    One more quicky, how do I make it display Intersection1 & Intersection2 such as "Street1 & Street2" in the line :

                                                    echo "<td>".$row['intersection1']."</td>\n";
                                                    echo "<td>".$row['intersection1'].$row['intersection2']."</td>\n";

                                                    Comment

                                                    • mkx
                                                      Confirmed User
                                                      • Nov 2003
                                                      • 4001

                                                      #27
                                                      Thanks again!

                                                      Comment

                                                      • over911
                                                        Confirmed User
                                                        • Jul 2002
                                                        • 1375

                                                        #28
                                                        Didnt know ya were into PHP V!

                                                        Nice

                                                        Comment

                                                        Working...