473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem creating a mysql database named M#2 using php

I am serving a website using apache. All the php and mysql code I have
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
help.
Jul 17 '05 #1
2 1755
On 5 Feb 2005 11:36:20 -0800, co**********@yahoo.com (cocoalearner) wrote:
I am serving a website using apache. All the php and mysql code I have
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);
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?
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
help.


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)
--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
Dear Andy,

Thank you, thank you, thank you. You solved my problem. When I
changed the single quotes to backticks the database was created just
fine. Thank you for your help.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ree | last post by:
I have a tables for a database that I have entried data in to. I have used the table on my local comp. and used apache & mySql to test it out. Now I need to upload the table to the site. But...
0
by: MLH | last post by:
I used the following SQL to create a new table in a database on a remote MySQL server by copying one already there. I know the table exists SOMEWHERE in cyberspace. I can read its data, write to...
3
by: konsu | last post by:
hello, i would like to write a batch file with all sql commands necessary to create a database, its tables, and populate them with initial data. would the experts please help me with these...
2
by: Saqib Ali | last post by:
I installed mySQL and have it running.... but I think I made a mistake somewhere along the line...... I believe I did follow the instructions that were provided with the distribution at:...
2
by: MLH | last post by:
I used the following SQL to create a new table in a database on a remote MySQL server by copying one already there. I know the table exists SOMEWHERE in cyberspace. I can read its data, write to...
2
by: Matt | last post by:
Stop me if you've heard this one... I want to create a "data dictionary" table of all my user tables in a certain database. The data dictionary (my version) will contain columns such as...
17
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
5
oll3i
by: oll3i | last post by:
my librarybean package library.ejb; import java.sql.*; import javax.ejb.*; import library.common.*; @Stateless @Remote
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.