You are here: Re: php script to create mySQL database programmatically « PHP Programming Language « IT news, forums, messages
Re: php script to create mySQL database programmatically

Posted by Jerry Stuckle on 10/31/06 17:23

mistral wrote:
> "Jerry Stuckle wrote:
> "
>
>>mistral wrote:
>>
>>>"Jerry Stuckle wrote:
>>>"
>
>
>>>>mistral wrote:
>>>>
>>>>
>>>>>"Jerry Stuckle wrote:
>>>>>"
>
>
>
>>>>>>mistral wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Need php script to create mySQL database programmatically; since
>>>>>>>hosting configuration may not allow create database from script, script
>>>>>>>also need eliminate/rewrite all restrictions in appropriate places in
>>>>>>>that hosting.
>>>>>>>
>>>>>>
>>>>>>You can make a script to create a database. But you can't make a script
>>>>>>which will hack the host's security settings.
>>>>>>
>>>>>>--
>>>>>>==================
>>>>>>Remove the "x" from my email address
>>>>>>Jerry Stuckle
>>>>>>JDS Computer Training Corp.
>>>>>>jstucklex@attglobal.net
>>>>>>==================
>>>>>
>>>>>======================================
>>>>>
>>>>>Need working code to create database programmatically via PHP.
>>>>>
>>>>>M.
>>>>>
>>>>
>>>>Not a problem. Here are some links to get you started:
>>>>
>>>>For the SQL you need:
>>>>
>>>>http://dev.mysql.com/doc/refman/5.1/en/create-database.html
>>>>http://dev.mysql.com/doc/refman/5.1/en/create-table.html
>>>>
>>>>And optionally:
>>>>
>>>>http://dev.mysql.com/doc/refman/5.1/en/create-index.html
>>>>
>>>>
>>>>From the PHP end, check out:
>>>>
>>>>http://www.php.net/manual/en/function.mysql-connect.php
>>>>http://www.php.net/manual/en/function.mysql-create-db.php
>>>>http://www.php.net/manual/en/function.mysql-select-db.php
>>>>http://www.php.net/manual/en/function.mysql-query.php
>>>>http://www.php.net/manual/en/function.mysql-close.php
>>>>
>>>>And for error processing, you'll want:
>>>>
>>>>http://www.php.net/manual/en/function.mysql-error.php
>>>>
>>>>This should get you started.
>>>>
>>>>--
>>>>==================
>>>>Remove the "x" from my email address
>>>>Jerry Stuckle
>>>>JDS Computer Training Corp.
>>>>jstucklex@attglobal.net
>>>>==================
>>>
>>>
>>>
>>>
>>>Code from php.net does not work..
>>>
>>><?php
>>>$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
>>>if (!$link) {
>>> die('Could not connect: ' . mysql_error());
>>>}
>>
>>>$sql = 'CREATE DATABASE my_db';
>>>if (mysql_query($sql, $link)) {
>>> echo "Database my_db created successfully\n";
>>>} else {
>>> echo 'Error creating database: ' . mysql_error() . "\n";
>>>}
>>>?>
>
>
>
>>>Warning: mysql_connect() [function.mysql-connect]: Can't connect to
>>>local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in
>>>/web/www/domain/users/u/username/createdb.php on line 2
>>>Could not connect: Can't connect to local MySQL server through socket
>>>'/var/run/mysqld/mysqld.sock' (2)
>
>
>>>Ugly, very ugly..
>
>
>>>m.
>
>
>
>>Are you running this on the server with MySQL installed? If so, it
>>looks like MySQL isn't running or the admin has it set up different from
>>the defaults.
>
>
>>Either way the only one who can tell you more is your hosting company.
>
>
>>--
>>==================
>>Remove the "x" from my email address
>>Jerry Stuckle
>>JDS Computer Training Corp.
>>jstucklex@attglobal.net
>>==================
>
>
> yes, installed. Just run phpinfo.php, it show the following MySQL
> related info :
>
>
> mysql
>
> MySQL Support: enabled
> Active Persistent Links: 0
> Active Links: 0
> Client API version: 5.0.24a
> MYSQL_MODULE_TYPE: external
> MYSQL_SOCKET: /var/run/mysqld/mysqld.sock
> MYSQL_INCLUDE: -I/usr/include/mysql
> MYSQL_LIBS: -L/usr/lib -lmysqlclient
>
> Directive Local Value Master Value
> mysql.allow_persistent: On On
> mysql.connect_timeout: 60 60
> mysql.default_host: no value no value
> mysql.default_password: no value no value
> mysql.default_port: no value no value
> mysql.default_socket: no value no value
> mysql.default_user: no value no value
> mysql.max_links: Unlimited Unlimited
> mysql.max_persistent: Unlimited Unlimited
> mysql.trace_mode: Off Off
>
>
> m.
>

This shows you what PHP thinks is installed. It may or may not match
the real installation, and even if it does match it doesn't mean MySQL
is currently running.

If MySQL support were not enabled, you would have gotten an "unknown
function" error message. But just because it's enabled doesn't mean it
works.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация