php script error help?
Results 1 to 7 of 7

Thread: php script error help?

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    5

    php script error help?

    Iv been following through a tutorial on making a news system with php and sql, after alof of noncing around iv managed to get most of the system to work except this error.

    Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in /home/welshywoo/www/read_more.php on line 5

    Can anyone help me out with the syntax for this script?

    <?php
    include("config.php");

    $newsid = $_GET['newsid];

    $result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect);
    while($myrow = mysql_Fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow['title'];
    echo "</b><br>On: <i>";
    echo $myrow['dtime'];
    echo "</i><hr>";
    echo $myrow['text1'];
    echo " ";
    echo $myrow['text2];
    echo "<br><br><a href=\"javascript:Self.history.back();\"><--Go Back</a>";
    }
    ?>
    cheers,

  2. #2
    Senior Member
    Join Date
    Mar 2004
    Posts
    557
    Hi

    line 5 ?

    What about these?
    Code:
    $newsid = $_GET['newsid];
    echo $myrow['text2];
    You may add a '

    Code:
    $newsid = $_GET['newsid'];
    echo $myrow['text2'];
    The structure of the query looks fine to me. I assume config.php is well defined?

    Cheers
    If the only tool you have is a hammer, you tend to see every problem as a nail.
    (Abraham Maslow, Psychologist, 1908-70)

  3. #3
    Senior Member WolfeTone's Avatar
    Join Date
    Jun 2007
    Location
    Ireland
    Posts
    197
    Code:
    <?php
    include("config.php");
    
    $newsid = $_GET[newsid];
    
    $result = mysql_query("SELECT * FROM news WHERE newsid='".$newsid."'",$connect);
    
    while($myrow = mysql_Fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow[title];
    echo "</b><br>On: <i>";
    echo $myrow[dtime];
    echo "</i><hr>";
    echo $myrow[text1];
    echo " ";
    echo $myrow[text2];
    echo "<br><br><a href=\"javascript:Self.history.back();\"><--Go Back</a>";
    }
    ?>
    or

    Code:
    <?php
    include("config.php");
    
    $newsid = $_GET[newsid];
    
    $result = mysql_query("SELECT * FROM news WHERE newsid='".$newsid."'",$connect);
    
    while($myrow = mysql_Fetch_assoc($result))
    {
    echo "<b>".$myrow[title]."</b><br>On: <i>".$myrow[dtime]."</i><hr>".$myrow[text1]." ".$myrow[text2]."<br><br><a href=\"javascript:Self.history.back();\"><--Go Back</a>";
    }
    ?>

  4. #4
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    Are you going to make this accessable from the Internet?

    If so, you might want to plug that SQL-Injection hole...
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  5. #5
    Junior Member
    Join Date
    Aug 2007
    Posts
    5
    got it working now, shoudlve checked my syntax better...
    cheers everyone,

  6. #6
    Senior Member WolfeTone's Avatar
    Join Date
    Jun 2007
    Location
    Ireland
    Posts
    197
    I'd say this is just a book he is following to learn php, not an actual script to be implemented.

  7. #7
    Member
    Join Date
    May 2005
    Posts
    93
    how about downloading php news system and from then on u may edit the system with your own style?

    or perhaps look at how the system flow.

    http://newsphp.sourceforge.net/downloads.php <---try this one.
    .sig na ture.

Similar Threads

  1. Replies: 0
    Last Post: August 30th, 2007, 04:33 AM
  2. Apache, PHP, MySQL with basic security settings.
    By nightcat in forum The Security Tutorials Forum
    Replies: 9
    Last Post: May 28th, 2005, 02:47 AM
  3. PHP Scriptonite - attacking/securing PHP
    By PuReExcTacy in forum Web Security
    Replies: 11
    Last Post: January 26th, 2005, 12:41 AM
  4. Installing Apache and PHP on Linux
    By HDD in forum Other Tutorials Forum
    Replies: 2
    Last Post: February 1st, 2004, 07:05 PM
  5. Date Encryption
    By CyberSpyder in forum AntiOnline's General Chit Chat
    Replies: 0
    Last Post: March 25th, 2003, 08:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides