tags:

views:

73

answers:

1

I have a situation, I have a mySql table named 'Master File' with contains 6000 records.

Howver I get an error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

My code looks as below.

$sql = "SELECT * FROM Master File";
$results = mysql_query($sql);


//Looping threw the Master File
while($row = mysql_fetch_array($results)){
    print_r($row);
}
+12  A: 
$sql = "SELECT * FROM `Master File`";

You need back ticks around fieldnames that have spaces.

dnagirl
awesome, learned something new
Roland
This will also help when the table contains fields that are named after reserved words in MySQL like 'group' and 'sum'. I have seen this happen to people before. You can use the back ticks on the field names too.
Buggabill