Maurice Posted January 28, 2007 Share Posted January 28, 2007 Hi all,currently I'm trying to create a simple mySQL database. Using the tutorials iver here I've come pretty far. Now I have a question.The following code (can be find on http://w3schools.com/php/php_mysql_select.asp ) gives me the error that the mysql_fetch_array() doesn't excist or is invalid. In the $result there can be found:$result = mysql_query("SELECT * FROM leden"); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "</tr>"; } Could somebody help me out on this, so I can read out the information from the 'leden' table? I think the error is the $row, so does the error from mysql thinks, but I don't know how to fix this. Complete code (copied from w3schools): <?php$con = mysql_connect("localhost","******","******");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("leden__DB__test", $con);$result = mysql_query("SELECT * FROM leden");echo "<table border='1'><tr><th>Voornaam</th><th>Achternaam</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['voornaam'] . "</td>"; echo "<td>" . $row['achternaam'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?> and the table 'leden' looks like this:-------------------------------| voornaam | achternaam ||-------------|---------------||Maurice | Krielaart ||Admin | Admin |-------------------------------Hope somebody can help me getting the data from the table into the browser page.Thanks in advanceMaurice Krielaart Link to comment Share on other sites More sharing options...
Maurice Posted January 28, 2007 Author Share Posted January 28, 2007 Never mind, I inserted the incorrect name for the database in the code, however thanks all! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now