Bug #1006: MySQL and Filereading won't work
| From: | Norbert dot Kuemin at gmx dot net | Date: | Fri, 25 Dec 1998 12:41:20 +0000 |
| Subject: | Bug #1006: MySQL and Filereading won't work | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3033@lists.php.net to get a copy of this message | ||
From: Norbert.Kuemin@gmx.net
Operating system: Linux 2.0.35
PHP version: 3.0.5
PHP Bug Type: MySQL related
Bug description: MySQL and Filereading won't work
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>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net