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..

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.