James Doe Jr.
James Doe Jr.

Reputation: 27

php INSERT INTO database variable name

When trying to use

$SomeTable = "SomeTable";
INSERT INTO "' . $SomeTable . '" SET ... 

instead of

INSERT INTO SomeTable SET ...

I am unsuccessful. Why am I unable to use a php variable to call a database name?

Upvotes: 1

Views: 96

Answers (1)

RyanS
RyanS

Reputation: 4194

You would need to use something like this:

$SomeTable = "SomeTable";
$query = 'INSERT INTO `' . $SomeTable . '` SET ... ';

Which uses the ` character instead of quotes

Upvotes: 2

Related Questions