Hello, I have been following this tutorial:
http://sephiroth.it/tutorials/flashPHP/news/index.php
I keep recieving a query error everytime i try to test it. I am a PHP beginner. I do not know for sure how i should be connecting to my server/host. I have been trying to do this kind of thing for about 6 months and i can’t work out how to connect etc. I really would be grateful of some help.
Here’s my code: (NB. My database is called “freemojo_news”, my table “news” and my fields “id”, “news” and “date”)
<?
$database = "freemojo_news";
$connection = mysql_connect ("localhost","","") or die ("Sorry, server error!");
mysql_select_db($database);
$query = "SELECT * FROM news ORDER BY date ASC";
$result = mysql_query($query) or die ("Sorry, query error!");
$num_rows = mysql_num_rows($result);
for($i=0;$i<$num_rows;$i++){
$row = mysql_fetch_array($result);
$news = "news$i";
$news = $row['news'];
$date = "date$i";
$date = $row['date'];
print("&news$i=$news");
print("&date$i=$date");
}
mysql_close($connection);
?>
If anyone can help i would appreciate it.
I am using phpmyadmin to create the database.
Thanks!
Andrew