Hi, Im trying to print the result of a db query... the code below isn't printing the moviePath or the author. Is the syntax of this correct.. I can't see the problem!!
$result = mysql_query("SELECT path, author FROM movies WHERE movieName = '$movie';",$db); if($result){ $row = mysql_fetch_row($result); $moviePath = $row['path']; $author = $row['author']; } printf("Movie Path: %s<br>\n ",$moviePath); printf("Movie Name: %s<br>\n ",$movie); printf("Author: %s<br>\n", $author);
Thanks, Rose
remove ; in the query
$result = mysql_query("SELECT path, author FROM movies WHERE movieName = '$movie'",$db);
Im afraid that hasn't made any difference... Any other suggestions??
I wasn't sure I had used the mysql_fetch_row correctly or not...
if ($row = mysql_fetch_array($result)) { $moviePath = $row['path'];
$author = $row['author']; }
printf("Movie Path: %s<br>\n ",$moviePath);
printf("Movie Name: %s<br>\n ",$author);
printf("Author: %s<br>\n", $author);
if you can't find the problem, add "or die()" at the end of each function, f.e.:
$query = mysql_query("your_query") or die(mysql_error());
Thanks Guys, Its working.... i changed it to this and theres no problem now.
$moviePath = $row[0]; $author = $row[1];
Thanks for your input