Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

max number of characters in database name?

Status
Not open for further replies.

mThomas

Instructor
May 3, 2001
404
US
Does PHP place a maximum numbers of characters that can be used in a database file name.

I have a mssql database connection that uses

"[abnavalthisnot-data-newsnow]"

All my scripts run just fine.

I created a test database by appending test to the database name. Now I have a connection using

"[abnavalthisnot-data-newsnowtest]"

When I try and run a script it returns an error:

Warning: mssql_select_db(): message: Unclosed quotation mark before the character string 'abnavalthisnot-data-newsnowte'. (severity 15) in D:\HTTP\test_site\enter.php on line 13

It does not appear to be reading the entire database name. I did some tests where I added extra characters to the name and it cuts the file name off after 28 characters.

I looked at the php.ini file and didn't find anywhere tht seems to control the max character length. It probably is in front of my nose :)

tia...mike
 
I doubt that it's a PHP limit. But there's a simple test:

[ol][li]Print the query to the browser[/li][li]Copy-and-paste the text of the query to some application that will run arbitrary queries against your database. An application like Microsoft's Query Analyzer.[/li][li]Run the query in the application[/li][/ol]

If you get the same error in QA, then it's a problem with your query.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Well, at first sight it seams to have nothing to do with database related limitations, but a simple error in your code. "Unclosed quotation mark" is pretty self explanatory, it basically means you missed some quote/apostrophe. Make sure you have all opened quotes/apostrophes closed, and that you escape any quote/apostrophe inside an opened string with the same character with a backslash (ex: $string = " PHP \"rules\"! "; ).

And don't worry, every programmer spends a nice bunch of hours total hunting this little mistakes down ;)

About your other question, I don't believe there's any limitation to the database name... Maybe 255 characters, but I don't really know, I've always used small database/table names.

jamesp0tter,
mr.jamespotter@gmail.com

p.s.: sorry for my (sometimes) bad english :p
 
The only difference between the working version and my test version is the addition of the test at the end of the file name. I think the reason it is returning the type of error is because the file name is being cut off and the closing quote is not being read.

I'll keep you posted.

tia...mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top