data from database
| From: | alain dhaene | Date: | Tue, 28 Oct 2003 19:45:07 +0000 |
| Subject: | data from database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-167918@lists.php.net to get a copy of this message | ||
Hi,
I will write a function that returns the result of a recordset.
I tried this:
Function getPersonen()
{
openDB(); //function that I implements in another file
$query = "SELECT * FROM Cursisten";
$result = mysql_query($query)
or die("Fout bij uitvoeren query");
$resultrow = mysql_fetch_array( $result );
closeDB(); //function that I implements in another file
mysql_free_result($result);
return $resultrow;
}
I call this function:
$resultaat = getPersonen();
// Printen resultaten in HTML
print "<table>\n";
while ($line = mysql_fetch_array($resultaat, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
In runtime I have the following error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in
/home/schoolre/public_html/Hitek/Online/Registratie/showPerson.php on line 8
What is wrong?
Alain