ArizonaJohn Posted June 8, 2009 Share Posted June 8, 2009 Hello, I would like to allow users to add tables to my database with special characters in the table names. The characters I would like to allow include #, &, *, and +. Below is my code which allows the users to create tables, and the name is the variable "$name". How can I allow them to use special characters for the table names? Thanks in advance, John if (isset($_POST['name']) && !empty($_POST['name'])) { mysql_connect("mysqlv10", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $table = mysql_real_escape_string($_POST['name']); $query = "CREATE TABLE `$table` (id INT(11) NOT NULL auto_increment, site VARCHAR(150) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site))"; Link to comment https://forums.phpfreaks.com/topic/161412-permitting-special-characters-in-mysql-tablenames/ Share on other sites More sharing options...
ldougherty Posted June 8, 2009 Share Posted June 8, 2009 http://dev.mysql.com/doc/refman/5.0/en/identifiers.html "Certain objects within MySQL, including database, table, index, column, alias, view, stored procedure, partition, and other object names are known as identifiers. This section describes the allowable syntax for identifiers in MySQL. Section 8.2.2, “Identifier Case Sensitivity”, describes which types of identifiers are case sensitive and under what conditions." Link to comment https://forums.phpfreaks.com/topic/161412-permitting-special-characters-in-mysql-tablenames/#findComment-851795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.