Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
February 5, 2005, 5:36 pm
rate this thread
written works, except for one thing. When I try to create a database
named M#2 using the following call, no database is created.
$db = 'M#2';
$query = "create database '$db'";
$result = @mysql_query($query);
I am able to create a database just fine using this technique when it
is named other things (such as M$B, or Global1). I am able to create
the database using CocoaMySQL. The MySQL documentation I read says the
only characters you cannot use are , . / and \, but they don't mention
"#". Also, it mentions that if you can have any database name that can
be used as a directory name. I am able to create a directory name in
unix called "M#2".
Any ideas about how to get this to work? Thank you in advance for any
Re: Problem creating a mysql database named M#2 using php
Removing the error suppression operator, checking $result and printing
mysql_error() may give some sort of clue.
Shouldn't you be using backticks `` to quote identifiers, i.e. the database
name, rather than single quotes '' which are for strings?
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 4.0.21
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database 'M#2';
ERROR 1064: You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use near
''M#2'' at line 1
mysql> create database `M#2`;
Query OK, 1 row affected (0.06 sec)
<http://www.andyhsoftware.co.uk/space Space: disk usage analysis tool