Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select data from a table where the table name has blank spaces in?

Tags:

php

mysql

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);
}
like image 683
Elitmiar Avatar asked Dec 05 '22 04:12

Elitmiar


1 Answers

$sql = "SELECT * FROM `Master File`";

You need back ticks around fieldnames that have spaces.

like image 52
dnagirl Avatar answered Dec 10 '22 11:12

dnagirl