MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 21st, 2000, 07:51 PM
Raze2k Raze2k is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 14 Raze2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello there. I'm new to MySQL, and I'm trying to use it in conjunction with PHP. However, I'm run into a stumbling block. I need to create a database and I don't have Telnet access, so I can't use any command line references.

Basically, here's the code that I managed:

<?php

$connection = mysql_connect("localhost","user","pass") or die ("Couldn't connect to server.");
$result = mysql_query("CREATE DATABASE $db_name", $connection);

if (!$result) {
die("Couldn't create $db_name database!");
} else {
echo "Database $db_name Has Been Created";
}
?>

Now I know that the connection isn't dying because the message that always appears on submittal (btw, $db_name is posted from a form), is that it couldn't create a database, not that it couldn't connect to MySQL. Help would be much appreciated.

Reply With Quote
  #2  
Old June 21st, 2000, 08:23 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
Try

$result = mysql_query("CREATE DATABASE $db_name", $connection) OR die(mysql_error());

That way you can see exactly what the MySQL error code is for that attempted query. Look at the MySQL documentation for that error code. (There is a searchable manual at www.mysql.com)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Help!! Database Prob..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT