Jump to content

[SOLVED] How to create database on mysql


akiratoya13

Recommended Posts

first of all what error does it give you ?

 

to create a database you would have to use the following command

 

CREATE DATABASE `test1` ;

 

which will create a database name test1

 

 

 

I wrote code like you..

CREATE DATABASE 'test' ;

 

I'm following your code and it get me : Parse error: parse error, unexpected T_STRING in C:\AppServ\www\test.php on line 3.

what was that?

 

before error it must because I didn't have database..

now I'm following from that site to create database

<?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";
}
?> 

 

and it gives me error :

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'mysql_user'@'localhost' (using password: YES) in C:\AppServ\www\test.php on line 2

Could not connect: Access denied for user 'mysql_user'@'localhost' (using password: YES)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.