Help - Search - Members - Calendar
Full Version: Can anyone tell me what's wrong with this script?
Movable Type Community Forum > Installing and Upgrading > Databases
nikolaus
I wrote a script to gather data from a MySQL database,

I keep getting a parse error in line 10, the one that starts with "while"...

Any idea wat could be wrong?

CODE
<?php
   /* Connecting, selecting database */
   $link = mysql_connect("localhost", "database", "password")
       or die("Could not connect");
   print "Connected successfully";
   mysql_select_db("base") or die("Could not select database");
    
$query = mysql_query('SELECT * FROM my_news');
    // get all the news in the 'news' table
while($news = mysql_fetch_array($query)) (
    echo "Title: " . $news['title'] . "n";
    echo $news['text'] . "n";
    echo "---------------------n";
)
?>
bmk
Right, okay... please keep the topics related to MT. smile.gif

Here's a sample query that will print the titles of your entries, you should be able to adjust that to work with your other table.

CODE
<?
// connection info at top

$query = mysql_query("SELECT * FROM mt_entry");

while($row = mysql_fetch_array($query)) {
$title = $row['entry_title'];
echo "$title <br />";
}
?>


And I think it's because you're using ( ), not { } like you should have. smile.gif
nikolaus
thnx!
girlie
And please don't start a new thread when you've already got one going.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.