Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
roland E W Mucke
Forum Newbie
Posts: 4 Joined: Thu Jun 16, 2005 2:56 pm
Location: New Zealand
Post
by roland E W Mucke » Fri Jun 17, 2005 6:27 am
Hi there,
I use different codes for connecting, create tables etc.etc. and everything seems to work. But unfortunatly I have this one problem not to be able to create a DB with PhP. I have to create the DB in a prompt and than fine, but not the Create DB with PhP ???.
My error message:
Code: Select all
Fatal error: Call to undefined function mysql_create_db()
I use different codes here as well i.e. PhP web site, but this is the easy one still no luck:
Code: Select all
<?
$link = mysql_connect("localhost","root", "Password");
if (! $link)
die("Couldn't connect to MySQL");
//create database
mysql_create_db("mydatabase")or die("Create Error: ".mysql_error());
mysql_close($link);
?>
Thanks for any help: aktell
Syranide
Forum Contributor
Posts: 281 Joined: Fri May 20, 2005 3:16 pm
Location: Sweden
Post
by Syranide » Fri Jun 17, 2005 7:38 am
straight from PHP documentation
For downwards compatibility mysql_createdb() can also be used. This is deprecated, however.
Not: The function mysql_create_db() is deprecated. It is preferable to use mysql_query() to issue a SQL CREATE DATABASE Statement instead.
Warning
This function will not be available if the MySQL extension was built against a MySQL 4.x client library.
Also, don't rely on this as a solution as it is very commonly not possible to create databases due to restrictions.
roland E W Mucke
Forum Newbie
Posts: 4 Joined: Thu Jun 16, 2005 2:56 pm
Location: New Zealand
Post
by roland E W Mucke » Fri Jun 17, 2005 4:45 pm
Hi there,
YES, you are right I tried this one already before and with no luck so ??? I’m still not better off. Anybody would not know by any chance how to get over the restriction as this is my only problem.
Thanks aktell
dnathe4th
Forum Newbie
Posts: 16 Joined: Fri Jun 17, 2005 2:01 pm
Post
by dnathe4th » Fri Jun 17, 2005 4:50 pm
what restriction? it just doesn't like u useing the depreciated function, thats all that error is saying
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Fri Jun 17, 2005 4:59 pm
Dude it's probably easier (and surely forwards and backwards compatible) just to do:
Code: Select all
mysql_query("CREATE DATABASE `foobar`") or die (mysql_error());
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Sat Jun 18, 2005 3:54 am
If this is in a hosting environment rather than on your test machine I imagine the mysql user you're connecting with won't have the CREATE priviledge. At least, if it's been set up by anyone with half a brain it won't have..