whizard
11-28-2005, 08:13 PM
Hi. I have some code which is supposed to list all the usernames in a database table.
include("login/db/dbconnection.inc");
$connect = mysql_connect($dbserver,$dbuser,$dbpass) or die("Could not connect to MySQL");
$db = mysql_select_db($dbselect,$connect) or die("Could not connect to database \"<strong>$dbselect</strong>\"");
$query = "SELECT * FROM `users`";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
print("<option value=\"$row[2]\">".$row[2]."</option>"); }
}
else
{
print("<option value=\"\">No users created yet</option>");
}
The problem is that I keep getting this result in the select box: No users created yet
I have several entries in the db however.
If anyone sees what I am doing wrong, could they tell me?
Thanks,
Dan
include("login/db/dbconnection.inc");
$connect = mysql_connect($dbserver,$dbuser,$dbpass) or die("Could not connect to MySQL");
$db = mysql_select_db($dbselect,$connect) or die("Could not connect to database \"<strong>$dbselect</strong>\"");
$query = "SELECT * FROM `users`";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
print("<option value=\"$row[2]\">".$row[2]."</option>"); }
}
else
{
print("<option value=\"\">No users created yet</option>");
}
The problem is that I keep getting this result in the select box: No users created yet
I have several entries in the db however.
If anyone sees what I am doing wrong, could they tell me?
Thanks,
Dan