Why this Script doesn't work with vanilla DB?

edited January 2007 in Vanilla 1.0 Help
Here is the script: //------------------------------ //Edit this parameters: //MySQL server adress $host="localhost"; //Username $user="askomm_tellus"; //Password $pass="***"; //Database $db="askomm_tellus"; //Table $table="LUM_Discussion"; //Show last x posts $laforums="5"; $link=mysql_connect($host, $user, $pass); $db=mysql_select_db($db); $query="select * from $table order by topic_time desc limit 0,$laforums"; $result=mysql_query($query, $link); while ($row=mysql_fetch_row($result)) { echo "<li><a href='http://www.domain.com/comments.php?DiscussionID=$row[0]' target='_blank'>$row[9]</a></li><br>"; }

Comments

  • umm where are yo putting it? in an extension?
  • edited January 2007
    noo in my webpage. This script have to show last 5 topics. It's no vanilla extension.
  • What error do you get?
  • Reply to whispered comment:
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/askomm/public_html/tellas/faq/faq.php on line 87 Line 87 is that : while ($row=mysql_fetch_row($result)) {
    To help track down the problem you need to be checking for errors. On the line before "while (" type this:
    echo mysql_error();

    Also to check that the database is assigned you can use an if statement to replace "$db=mysql_select_db($db);"
    if (!$db=mysql_select_db($db)) echo 'select db failed';
    Same goes for $link=...
This discussion has been closed.