Help with string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shihan
Forum Newbie
Posts: 1
Joined: Thu Feb 23, 2012 11:41 am

Help with string

Post by shihan »

Hi there,

I'm new in php coding so I need little help.

I need to find way to create table trough php code but with name of table from string. How to write that correct
here is example of my needs

$query ='CREATE TABLE $table_name (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT,
`vis_name` VARCHAR( 50 ) NOT NULL,
`vis_key` VARCHAR( 50 ) NOT NULL,
`date` DATETIME NOT NULL,

PRIMARY KEY ( `id` )
)';

Thank you in advance
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help with string

Post by Celauran »

Variables aren't parsed inside single quotes. Use double quotes and the code you posted should work fine.
Post Reply