Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

PHP gurus. Need help with this. Trying to use php to create a database.

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

PHP gurus. Need help with this. Trying to use php to create a database.

Old 09-09-04, 01:42 PM
  #1  
Video Game Talk Reviewer
Thread Starter
 
Canis Firebrand's Avatar
 
Join Date: Dec 1999
Location: Formerly known as "Vryce"/Detroit, Michigan
Posts: 13,856
Likes: 0
Received 1 Like on 1 Post
PHP gurus. Need help with this. Trying to use php to create a database.

So, I have a script I'm writing to help do some database management for times I can't get into phpmyadmin.

I am having problems with adding a database.

I took out that part of my script and created a small php file that looks like this.



mysql_connect("localhost","user","dbpass");
mysql_query("CREATE DATABASE cpnlname_dbname") or die (mysql_error());
echo "Your database should be created now.";
Where dbuser is the username I use and dbpass is my password.
cpnlname_dbname I substitue in the name of the database I want to create.

When I try, I get the following error

Error creating database: Access denied for user: '[email protected]' to database 'cpnlname_dbname'

However, if I use the name of a database that had existed at one point, but doesn't now. It works with no problems and creates the database.
But, when I try a database name that never existed, it gives the above error message.

I can use the same user and password to get into myphpadmin and create the database that way. So I know I am using the correct username and password.

Any help at all would be great.
Its the last part of my php code that is driving me nuts, because it should work.
Old 09-09-04, 02:42 PM
  #2  
DVD Talk Special Edition
 
Join Date: Sep 1999
Location: Bristol, CT USA
Posts: 1,861
Likes: 0
Received 0 Likes on 0 Posts
Does

mysql_connect("localhost","user","dbpass");
mysql_query("CREATE DATABASE cpnlname_dbname") or die (mysql_error());
echo "Your database should be created now.";

create the "access denied for user: '[email protected]'..." error? Or does

mysql_connect("dvdtalk","vryce","dbpass");
mysql_query("CREATE DATABASE cpnlname_dbname") or die (mysql_error());
echo "Your database should be created now.";

create the "...'[email protected]'..." error?

Dan
Old 09-09-04, 03:00 PM
  #3  
Video Game Talk Reviewer
Thread Starter
 
Canis Firebrand's Avatar
 
Join Date: Dec 1999
Location: Formerly known as "Vryce"/Detroit, Michigan
Posts: 13,856
Likes: 0
Received 1 Like on 1 Post
The code I posted, I just stripped out my username and password and put in the generic terms.


it returns access denied for user": '[email protected]'..."

which is strange, because if I try to create a database that at one time existed, but doesn't anymore, it creates the database with no problems.

Its really stumpping me.

Last edited by Canis Firebrand; 09-09-04 at 03:14 PM.
Old 09-09-04, 03:11 PM
  #4  
DVD Talk Gold Edition
 
Demontooth's Avatar
 
Join Date: Jan 2001
Location: Green Acres
Posts: 2,050
Likes: 0
Received 0 Likes on 0 Posts
Old 09-09-04, 08:01 PM
  #5  
DVD Talk Hall of Fame
 
Join Date: Jan 2000
Location: US
Posts: 9,631
Likes: 0
Received 0 Likes on 0 Posts
Dumb question, but the user name you are using does have create priv's, and access from the localhost right?

dave
Old 09-10-04, 07:30 AM
  #6  
Video Game Talk Reviewer
Thread Starter
 
Canis Firebrand's Avatar
 
Join Date: Dec 1999
Location: Formerly known as "Vryce"/Detroit, Michigan
Posts: 13,856
Likes: 0
Received 1 Like on 1 Post
I would assume it does.

I can create a database with no problems using phpmyadmin, whether it is one that existed in the past or is brand new.

And, using my script, I can create a database that existed at oe time, but not presently.

I cannot use my script to create a database that never existed.

My script is using the same username and password that I log into myphpadmin with.

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information -

Copyright 2021 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.