it works, thanks,
Alain "John Nichel" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > alain dhaene wrote: > > 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 ); > > Get rid of the above line, unless you plan on passing the array. From > the looks below, you want to pass the identifier though. If you do want > to pass the result array instead of the identifier, leave as is. > > > closeDB(); //function that I implements in another file > > mysql_free_result($result); > > If you are going to pass the identifier, you just killed it here. If > you are going to pass the data array, swap these two lines, ie free your > result before you close your connections. > > > return $resultrow; > > Change this line to... > > return $result > > if you are not planning on passing the array. > > > } > > > > I call this function: > > > > $resultaat = getPersonen(); > > // Printen resultaten in HTML > > print "<table>\n"; > > while ($line = mysql_fetch_array($resultaat, MYSQL_ASSOC)) { > > What you do with this, all depends on how you rewrite your function. If > you're passing the identifier, you can leave it as is, if you're passing > the result data array, you need to get rid of the while loop. > > > 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? > > Alot, I suggest you check out the MySQL functions.... > > http://us4.php.net/manual/en/ref.mysql.php > > -- > By-Tor.com > It's all about the Rush > http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php