954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Create table variable with spaces

I have a variable $topic = $POST_['topic'] that is entered by the user, it can possibly have spaces. I want to create a table based on this variable. Right now the code creates the table but only uses the first word.

$create="Create TABLE $topic (I know this part works)";
mysql_query($create);


I tried adding single quotes to

$create="Create TABLE '$topic' (I know this part works)";
mysql_query($create);


but it still only uses the first word to create the table. any suggestions?? Sorry for the lack of code but im at work right now so i can't remember the entire code by memory.. lol...

Thanks in Advance!!!

RazorRamon
Junior Poster in Training
74 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

http://dev.mysql.com/doc/refman/5.6/en/identifiers.html

Try with backticks. The topic may not end with a space.

pritaeas
Posting Expert
Moderator
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: