[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 02-22-2007, 09:59 PM   #1 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


Making a new database in PHP

Hey
is there a way to make a new Database in PHP? in a php script...i cant figure it outt...Thanks
unknowngiver is offline  
Old 02-23-2007, 12:09 AM   #2 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


I'm not sure, but I believe the command to use is create database
PHP Code:
<?php
// Possibly something like this:
mysql_connect('blah', 'blah', 'blah);
mysql_query('
create database blah');
mysql_close();
?>
Barrucadu is offline  
Old 02-23-2007, 12:55 AM   #3 (permalink)
Senior Member
 
shockie's Avatar
 
Join Date: Dec 2006
Posts: 4,478
1,025.10 NP$ (Donate)

shockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond repute


uh... i don't think that will work. when you make a database you need to specify the type(s) of data you are feeding into it... if you can anticipate this then just make a blank database.
shockie is offline  
Old 02-23-2007, 01:30 AM   #4 (permalink)
NamePros Regular
 
Join Date: Apr 2004
Location: NL
Posts: 827
316.85 NP$ (Donate)

Slewey is just really niceSlewey is just really niceSlewey is just really niceSlewey is just really nice


the types of data are specified in the tables;

you can create a database with
PHP Code:
$query  = "CREATE DATABASE test_database";
$result = mysql_query($query);
or
PHP Code:
mysql_create_db('test_database');
After that you can select that database and create tables in it
PHP Code:
mysql_select_db('test_database') or die('Cannot select database');

$query = 'CREATE TABLE users( '.
         
'id INT NOT NULL AUTO_INCREMENT, '.
         
'name VARCHAR(20) NOT NULL, '.
         
'email VARCHAR(50) NOT NULL, '.
         
'message TEXT NOT NULL, '.
         
'PRIMARY KEY(id))';

$result = mysql_query($query);
__________________
xmpv.com | nuwp.com | frot.info |
Slewey is offline  
Old 02-23-2007, 05:45 AM   #5 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
as Slewey states you can use the mysql_create_db function but the user you connect with must have permissions to create a database.
Peter is offline  
Old 02-23-2007, 11:48 AM   #6 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


well i can make databases through cpanel..but i cant seem to do it using PHP...in the user thing..do i put my username and password for Cpanel/
unknowngiver is offline  
Old 02-23-2007, 11:53 AM   #7 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


Quote:
Originally Posted by unknowngiver
well i can make databases through cpanel..but i cant seem to do it using PHP...in the user thing..do i put my username and password for Cpanel/
No, in cPanel you must make a user with the ability to make a database. Then you use those user's details when conencting via php.
Barrucadu is offline  
Old 02-23-2007, 12:00 PM   #8 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


Access denied for user 'funny_dbmaker'@'%' to database 'funny_blah'

in cpanel there is no way of setting a user to make databases i think? u can only assign a user to specific databases 2 perform stuff on them..
unknowngiver is offline  
Old 02-24-2007, 01:51 AM   #9 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
Originally Posted by unknowngiver
well i can make databases through cpanel..but i cant seem to do it using PHP...in the user thing..do i put my username and password for Cpanel/
cPanel uses the adminitrator account if I remember correctly to create a database. Just had a look at the mysql user creation page as well and it seems that cPanel does not give the ability to let an account create a database 9only tables hence the create privaleges)
Peter is offline  
Old 02-24-2007, 06:48 PM   #10 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


So theres no way of making databases in PHP?

btw i remember seeing a site [some1 posted it on namepros] once where u typed in your cpanel information 2 make newdatabses throuigh that site..so it should be possible i guess?
unknowngiver is offline  
Old 02-25-2007, 02:00 AM   #11 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
Originally Posted by unknowngiver
So theres no way of making databases in PHP?
Only if the user you are connecting with has the privileges to create a database and cpanel does not allow you to give that right.

Quote:
Originally Posted by unknowngiver
btw i remember seeing a site [some1 posted it on namepros] once where u typed in your cpanel information 2 make newdatabses throuigh that site..so it should be possible i guess?
They most likely used cURL which would simulate someone doing it manually.

EDIT
----

Just had a look and the following seems to be the sort of script you mean http://www.zubrag.com/scripts/cpanel...se-creator.php

Quote:
cPanel does not allow you to create databases directly from MySQL/PhpMyAdmin on cPanel webhosting. You would have to login to cPanel and use its interface to create database each time you need a new one.
cPanel Database Creator will make this process much easier. In order to create a database on your hosting server you just need to run this script from browser, shell, or cron job, passing database name as parameter.
If you look on the site you will see the system requirements are that cURL is installed. This will basically log into cPanel and basically act as if you were creating it yourself.

Last edited by filth@flexiwebhost; 02-25-2007 at 02:11 AM.
Peter is offline  
Old 02-25-2007, 06:31 PM   #12 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


hm pretty gud buh how would u add a user now?
unknowngiver is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:47 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85