Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: PHP Error

  1. #1
    Pro Member 308holes is an unknown quantity at this point 308holes's Avatar
    Join Date
    Aug 2001
    Location
    n/a
    Posts
    258

    PHP Error

    Hello all im having a problem it saying i have a error on my code and i dont know what it is.... says line17.. Please help

    PHP Code:
    //News.php
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Lemo News</TITLE>
    <LINK REL=stylesheet HREF='ikonboard.css' TYPE='text/css'>
    </HEAD>
    <BODY BGCOLOR=49525D BACKGROUND="hardwired_bak.gif" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
    <?php
       
    require("VAR.php");
       
    $LINK      mysql_connect($HOST,$USER,$PASSWORD);
       
    $QUERY     "SELECT * from $DBTABLE";
         
    $RESULT    mysql_db_query($DBNAME,$QUERY,$LINK);

         while(
    $ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
            
    <p>NAME:$ROW[NAME]</p>
            <
    p>TIME:$ROW[TIME]</p>
            <
    p>DATE:$ROW[DATE]</p>
            <
    p>NEWS:$ROW[NEWS]</p>
         }
         
    mysql_close($LINK);
    ?>
    </BODY>
    </HTML>

    //VAR.php
    <?php
    $HOST      
    "localhost";
    $USER      "NAME";
    $PASSWORD  "PW";
    $DBNAME    "News";
    $DBTABLE   "DBNews"
    ?>
    Last edited by 308holes; February 3rd, 2003 at 01:54.
    Sic vis pacem para bellum
    "If You Want Peace Prepare For War"

  2. #2
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    use this:
    PHP Code:
    while($ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
            
    echo "<p>NAME:$ROW[NAME]</p>
            <p>TIME:$ROW[TIME]</p>
            <p>DATE:$ROW[DATE]</p>
            <p>NEWS:$ROW[NEWS]</p>"
    ;
         }
         
    mysql_close($LINK); 
    There are 3 kinds of people: the ones who can count and the others who cannot

  3. #3
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    make sure you put quotes around the array names ($ROW['NAME']).

  4. #4
    Senior Member Salam is an unknown quantity at this point
    Join Date
    Aug 2002
    Location
    Tehran/IRAN
    Posts
    141
    And also { and } : "<p>{$ROW['NAME']}</p>"

  5. #5
    Pro Member 308holes is an unknown quantity at this point 308holes's Avatar
    Join Date
    Aug 2001
    Location
    n/a
    Posts
    258
    Ok i tried this and getting erros still

    PHP Code:
    <?php
       
    require("VAR.php");
       
    $LINK      mysql_connect($HOST,$USER,$PASSWORD);
       
    $QUERY     "SELECT * from $DBTABLE";
        
    $RESULT    mysql_db_query($DBNAME,$QUERY,$LINK);

         while(
    $ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
            
    <p>NAME:{$ROW['NAME']}</p>
            <
    p>TIME:{$ROW['TIME']}</p>
            <
    p>DATE:{$ROW['DATE']}</p>
            <
    p>NEWS:{$ROW['NEWS']}</p>
         }
         
    mysql_close($LINK);
    ?>
    Sic vis pacem para bellum
    "If You Want Peace Prepare For War"

  6. #6
    VIP conkermaniac is on a distinguished road conkermaniac's Avatar
    Join Date
    Dec 2001
    Location
    China--soon to be Cambridge MA
    Posts
    5,794
    You're still missing the "echo" in the while loop!
    a.aimoo.com - Get your forum reviewed here!
    desilva.biz - Great webmaster tips and tricks!
    webmaster-talk.com - Discussion forum for all webmasters

  7. #7
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    Yes, you are still missing the echo, but if it still produces errors, it may be the data your trying to print --if the content in "news" contained quotations, then it will cause an error, so it might be best to use htmlspecialchars() to escape the spcial HTML that may be inside of the variables.

  8. #8
    Pro Member 308holes is an unknown quantity at this point 308holes's Avatar
    Join Date
    Aug 2001
    Location
    n/a
    Posts
    258
    The Variables are all Formatted as Text and i get an error on the first p tag"<p>NAME:{$ROW['NAME']}</p>"

    PHP Code:
    <?php
       
    require("VAR.php");
       
    $LINK      mysql_connect($HOST,$USER,$PASSWORD);
       
    $QUERY     "SELECT * from $DBTABLE";
       
    $RESULT    mysql_db_query($DBNAME,$QUERY,$LINK);

         while(
    $ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
             
    print(<p>NAME:$ROW['NAME']</p>);
             print(<
    p>TIME:$ROW['TIME']</p>);
            print(<
    p>DATE:$ROW['DATE']</p>);
                print(<
    p>NEWS:$ROW['NEWS']</p>);
         }
         
    mysql_close($LINK);
    ?>
    this is the data in the MySQL Database
    Code:
    Webmaster    12:30:15PM   01/31/2003    Hello This is a Test
    Last edited by 308holes; February 4th, 2003 at 16:55.
    Sic vis pacem para bellum
    "If You Want Peace Prepare For War"

  9. #9
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    Now your not putting quotes

    PHP Code:
    print "<p>NAME:$ROW['NAME']</p>";
    print 
    "<p>TIME:$ROW['TIME']</p>";
    print 
    "<p>DATE:$ROW['DATE']</p>";
    print 
    "<p>NEWS:$ROW['NEWS']</p>"

  10. #10
    Pro Member 308holes is an unknown quantity at this point 308holes's Avatar
    Join Date
    Aug 2001
    Location
    n/a
    Posts
    258
    Ok THis is the Error i get now
    Code:
    parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
    and the code im useing
    PHP Code:
    <?php
       
    require("VAR.php");
       
    $LINK      mysql_connect($HOST,$USER,$PASSWORD);
       
    $QUERY     "SELECT * from $DBTABLE";
       
    $RESULT    mysql_db_query($DBNAME,$QUERY,$LINK);

         while(
    $ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
             
    print("<p>NAME:$ROW['NAME']</p>");
             print(
    "<p>TIME:$ROW['TIME']</p>");
            print(
    "<p>DATE:$ROW['DATE']</p>");
                print(
    "<p>NEWS:$ROW['NEWS']</p>");
         }
         
    mysql_close($LINK);
    ?>
    Sic vis pacem para bellum
    "If You Want Peace Prepare For War"

  11. #11
    FWS Addict spec is an unknown quantity at this point
    Join Date
    Jun 2001
    Posts
    712
    while($ROW = mysql_fetch_arry($RESULT))
    replace with
    while($ROW = mysql_fetch_array($RESULT))

  12. #12
    Pro Member 308holes is an unknown quantity at this point 308holes's Avatar
    Join Date
    Aug 2001
    Location
    n/a
    Posts
    258
    Code:
    parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
    Sic vis pacem para bellum
    "If You Want Peace Prepare For War"

  13. #13
    Member Cyber-Scripter is an unknown quantity at this point
    Join Date
    Dec 2002
    Location
    USA
    Posts
    82
    Couldn't you use this?
    PHP Code:
    echo "<p>".$ROW['NAME']."</p>";
    echo 
    "<p>".$ROW['TIME']."</p>";
    echo 
    "<p>".$ROW['DATE']."</p>";
    echo 
    "<p>".$ROW['NEWS']."</p>"
    Also, did you use capital letters when you made the row names? So it might be like this:
    PHP Code:
    echo "<p>".$ROW['name']."</p>";
    echo 
    "<p>".$ROW['time]."</p>";
    echo "<p>".$ROW['
    date']."</p>";
    echo "<p>".$ROW['
    news]."</p>"
    I no expert though, just a beginner.
    Never ever pet the monkey....[/URL]

  14. #14
    Pro Member Cagez is an unknown quantity at this point Cagez's Avatar
    Join Date
    Oct 2002
    Location
    Toronto, Ontario
    Posts
    457
    Thats right Cyber-Scripter. 308holes , make sure you have the right variable name's and key's, $row['this'] is different from $ROW['THIS']...

  15. #15
    Senior Member Salam is an unknown quantity at this point
    Join Date
    Aug 2002
    Location
    Tehran/IRAN
    Posts
    141
    Originally posted by 308holes
    and the code im useing
    PHP Code:
    <?php
       
    require("VAR.php");
       
    $LINK      mysql_connect($HOST,$USER,$PASSWORD);
       
    $QUERY     "SELECT * from $DBTABLE";
       
    $RESULT    mysql_db_query($DBNAME,$QUERY,$LINK);

         while(
    $ROW mysql_fetch_arry($RESULT))
         {
          
    //Place News in HTML Fields
             
    print("<p>NAME:$ROW['NAME']</p>");
             print(
    "<p>TIME:$ROW['TIME']</p>");
            print(
    "<p>DATE:$ROW['DATE']</p>");
                print(
    "<p>NEWS:$ROW['NEWS']</p>");
         }
         
    mysql_close($LINK);
    ?>
    You forgot { and } :
    print("<p>NAME:{$ROW['NAME']}</p>");

Closed Thread

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