|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1998-12-25 10:24 UTC] rasmus
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
If I do some filereadings before I access the mysql db I get the following Warning: Warning: 1 is not a MySQL link index in /usr/local/www/lugs/test/test.phtml on line 30 Every function for it self work perfectly. And here the file: <html> <head></head> <body> <? function read_file () { $filename = "/etc/hosts"; if (is_readable($filename)) { $fp = fopen($filename, "r"); if ($fp) { echo "<pre>\n"; while (!feof($fp)) { $line = fgets($fp,1024); echo $line; } echo "</pre>\n"; } } else { echo "<b>File $filename is not readable.</b>\n"; } } function read_mysql () { $link_id = mysql_connect("localhost","root",""); if (!$link_id) { exit; } $db_id = mysql_select_db("mysql",$link_id); if ($db_id) { $result_id = mysql_query("SELECT * FROM user",$db_id); if ($result_id) { $amount = mysql_num_rows($result_id); echo "Amount:$amount<p>\n"; echo "<table border=1><tr><th>Host</th><th>User</th></tr>\n"; for ($i=0;$i < $amount;$i++) { $host = mysql_result($result_id,$i,Host); $user = mysql_result($result_id,$i,User); echo "<tr><td>$host</td><td>$user</td></tr>\n"; } echo "</table>\n"; } } mysql_close($db_id); } read_file (); read_mysql (); ?> </body> </html>