Page 1 of 1

mysql_fetch_array plus other errors

Posted: Tue Apr 20, 2004 4:39 pm
by ehause
Hi all:

Whew, I should take a class....but I'm one of those stubbornm teach-yourself guys.

Anywhoo, I am trying to create a pull-down menu of variables from a table named "categories" in my database that the user selects. Here's the code I used to create the table:

// --------- DISPLAY THE FORM ---------

// Create the pull-down menu information.
$query = "SELECT * FROM categories ORDER BY type ASC";
$result = @mysql_query ($query);
$pulldown = '<option>Select One</option>
';
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
$pulldown .= "<option value=\"{$row['category_id']}\">{$row['category']}</option>\n";
}

In the HTML, here's what I used to display:

<td><font face="Arial,Helvetica,sans-serif" size="2" color="#000000"><b>Business Category:</b> </td>
<td><select name="category">
<?php echo $pulldown; ?>
</select></td>
</tr>

I'm successfully connecting to and inserting into the database prior to adding this code.

When I run the script, here's the error the config.inc file gives me:

An error occurred in script /home/souther2/public_html/templates/config.inc on line 10: mysql_query(): Access denied for user: 'souther2@localhost' (Using password: NO)

An error occurred in script /home/souther2/public_html/templates/config.inc on line 10: mysql_query(): A link to the server could not be established

An error occurred in script /home/souther2/public_html/templates/config.inc on line 10: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Ideas? Thanks for all your help today--I know I've been a pain in the butt.

Eric

Posted: Tue Apr 20, 2004 4:47 pm
by MarK (CZ)
Is the combination user / password / host correct??

Posted: Tue Apr 20, 2004 4:51 pm
by ehause
Yes, I've verified that. Before I added this code, I could connect to the DB just fine. Not sure why I'm not able to just with the addition of this code.

EMH

Posted: Tue Apr 20, 2004 4:52 pm
by MarK (CZ)
Maybe this user doesn't have privileges only to THIS one table, does it?