Date: 07/14/01
- Next message: zombie <email protected>: "[PHP-DEV] Bug #12169: Doesn't work"
- Previous message: eschmid <email protected>: "[PHP-DEV] Bug #12167 Updated: Bug in function.array-keys.php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: DeadEye5000 <email protected>
Operating system: Windows 2000
PHP version: 4.0.6
PHP Bug Type: MySQL related
Bug description: mysql_select_db() won't work
This is a two part script, query.php and mysqltest.php. It's a script that
executes a query on the selected database. But I get an error that says
that there is no database selected. I'm using IIS 5. This is the first
page:
<html>
<head>
<title>PHP Code Tester</title>
</head>
<body>
<!-- query.php -->
<?
$host = "localhost";
$user = "dan";
$pass = "moops";
?>
<form action="mysqltest.php">
Please select the database for query:<br><br>
<select name=database>
<?
mysql_connect($host, $user, $pass);
$dbTable = mysql_list_dbs();
for ($i = 0; $i < mysql_num_rows($dbTable); $i++) {
echo "<option value=\"" . mysql_tablename($dbTable, $i) . "\">" .
mysql_tablename($dbTable, $i) . "\n";
}
?>
</select>
<br><hr>
Please input the SQL Query to be executed:<br><br>
<textarea name="query" cols=50 rows=10></textarea><br><br>
<input type=submit value="Execute Query!">
</form>
</body>
</html>
Sorry if this is a bit long, but this is the second page:
<html>
<head>
<title>PHP SQL Code Tester</title>
</head>
<body>
<!-- mysqltest.php -->
<?
$host = "localhost";
$user = "dan";
$pass = "moops";
mysql_connect($host, $user, $pass);
$query = stripSlashes($query);
$result = mysql_db_query($database, $query);
?>
Results of query <b><? echo $query; ?></b><hr>
<?
if ($result == 0):
echo "<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>";
elseif (mysql_num_rows($result) == 0):
echo "Query executed successfully!</b>";
else:
?>
<table border=1>
<tr>
<?
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo "<td>" . mysql_field_name($result, $i) . "</td>";
}
?>
</tr>
<?
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo "<tr>";
$rowArray = mysql_fetch_rows($result);
for ($j = 0; $j < mysql_num_fields($result); $j++) {
echo "<td>" . $rowArray[$j] . "</td>";
}
echo "</tr>";
}
?>
</table>
<? endif ?>
<hr><br>
<form action=query.php method=post>
<input type=submit value="New Query">
</form>
</body>
</html>
I'm using the win32 binary of PHP. While I was installing PHP it ran into
an error saying it couldn't configure for IIS, and that I had to manually
do it. I set it up and all the scripts run fine except for when I have to
select a database.
-- Edit bug report at: http://bugs.php.net/?id=12168&edit=1-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: zombie <email protected>: "[PHP-DEV] Bug #12169: Doesn't work"
- Previous message: eschmid <email protected>: "[PHP-DEV] Bug #12167 Updated: Bug in function.array-keys.php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

