Jump to content

Query returns column name instead of row values


doni49

Recommended Posts

This is a code snippet from my PHP file.
[code]
        $query = "SELECT 'setName', 'fields' FROM userFieldSets WHERE user_id='$uid'";
        $result = @mysql_query ($query) or die ('I cannot get fields from the database because: ' . mysql_error());
        $row = mysql_fetch_array ($result, MYSQL_NUM);

        if ($row) { // A match was made.
            echo "0:  " . $row[0] . "<br>";
            echo "1:  " . $row[1] . "<br>";
        }        
[/code]

It shows this in my browser.
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
0: setName
1: fields
[/quote]

This is copy/pasted from phpMyAdmin.
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
[b]id user_id tblName setName fields
[/b]1 1 mainIndex Default 1,2,3,4,5,6,7,8,10,13,14
2 1 propertyAmtsDue Default 1,2,3,4,5,6,7,8,10,13,14
3 1 propertyContact Default 1,2,3,4,5,6

[/quote]

That's strange. I only put them in there because I was getting error messages that there was something wrong with the syntax.

When I put them in the error message went away.

Is "Fields" a reserved name or something?

While waiting to hear from someone, I kept trying different things. I changed "Fields" to "Flds" and still got the column names anyway. But then as soon as I took the quotes back out, it worked fine (with it still using "Flds").

Thanks for the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.