Ok, I don't know what's going on.
The best I can describe it is simply "it isn't working"
I've got a MySQL database that contains a table with names and id numbers of categories...
(table is called subsection, in the testing database (no username or password needed as far as i can tell)... relevant field is sub_name - a varchar with a length of 50)
All I want to do, is make a php page which selects all the category names from the table, and prints them on the screen...
I've done it plenty of times before but for some reason it has decided to not work.
This is bizarre, since I just copied and pasted the code from another site on the same computer etc... that one doesn't have any problems with it...
The relevant code....
$db_conn = @mysql_pconnect('localhost', 'testing');
if (!$db_conn)
{//handle error
echo 'Error connecting to database.';
exit;
}
else
mysql_select_db('testing', $db_conn);
...
$query = "SELECT sub_name FROM subsection";
$query_result = mysql_query($query, $db_conn);
if (!$query_result)
{
echo '??';
}
$num_subs = mysql_num_rows($query_result);
for ($i=0; $i < $num_subs; $i++)
{//For each subsection...
$subsection_name = mysql_fetch_array($query_result);
echo $subsection_name['sub_name'].'<br />';
}
All that appears is the ?? telling me that the query failed....
I'm not sure what is going wrong - other sites on the computer I've made seem to be able to access their databases (although I think there's something going wrong with the session variables, because when i log in, it seems to work but then acts as if i havn't logged in)...
What could be causing this?
It's probably something blatantly obvious... btw this is the first time I've coded anything since formatting, so it may be a setting I have forgotten needs to be set.. or maybe something with permissions....
Any ideas?
Thanks
Kefka