PDA

View Full Version : Flash & PHP news system: keep getting query error


free mojo
02-23-2005, 01:38 PM
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

bob_la_matraque
02-23-2005, 03:26 PM
Should work. Are you sure of your database, table and fields names? (furthemore ASC is optional)

Try other request more general... SELECT * FROM user_tables or SELECT * FROM news.

Strange.

free mojo
02-23-2005, 03:59 PM
Thanks for replying!
That's what i thought, there (as far as i know) shouldn't be a reason it doesn't work and i've checked it.

I think it's definitely something to do with how or if i'm connecting/contacting my database at all. I don't really understand that.

I can explain anything else. If anyone else has done something similar with phpmyadmin it might help.

Thanks though.
:confused:

andehlu
02-27-2005, 02:39 AM
looks fine to me.... do you get an error returned when running the php script?