<html> <head><title>MySQL GuestBook 1.0</title> </head> <body> <font face=verdana size=2px> <center> <?php include("config.inc.php"); $conn = mysql_connect($host) or die("Could not connect to host"); $database = mysql_select_db($db); $query = "SELECT * FROM " . $table . ""; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo "<br> From <b><a href=mailto:" . $row[email] . ">" . $row[name] . "</a></b> on " . $row[date] . "<br><i>" . $row[comment] . "</i><br><hr size=4 width=260><br>"; } mysql_close($conn); ?> <br><br><br> <a href="mSignForm.php">Sign the guestbook</a><br> (C) <a href="mailto:IskallPl@hotmail.com">Uis</a> 2003<br> </center> </body> </html>
it keeps on giving me
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/chaotici/public_html/community/spoono/guestbook/index.php on line 17
Where's $table come from? Use mysql_error().
$result = mysql_query($query) or die(mysql_error());
Nothing to do with HTML and PHP. It's a problem with either your SQL or your connectioon to the MySQL server.
i'm guessing $table's coming from his config.inc.php..... but what's with only passing a host to mysql_connect? are you using ini entries for the user/pw?
yeah, when he logs in he can only see his messages not other people's.
why would you fetch_array with $result and not $query?
because $query is a string and $result is a recordset resource. $ query is nothing more thatn the SQL staement, $result is a way to manipulate what mysql did with that statement.