Jump to content

I have been trying 4 days now to create database, but I cant


Recommended Posts

I have been trying to create database

 

This is the code I am using

 

<HTML>
<HEAD>
<TITLE>Connect & Create</TITLE>
<BODY>

<?php

$con = mysql_connect("localhost","my name","my password");


if ($con) {

      print("Done connecting<BR>\n");

} else {

      print("Not done connecting<BR>\n");
  
}


if (mysql_create_db ("Newdatabase", $con)) {

      print("Created<BR>\n");

} else {

      print("Not Created<BR>\n");
}

mysql_close($con);


?>

</HEAD>
</BODY>
</HTML>

 

 

This is the result I get:

 

Done connecting

 

Fatal error: Call to undefined function: mysql_create_db() in /home/npsari/public_html/trials/connectcreateinternet.php on line 23

hey, thanks!

 

However, this time it tells me:

 

Access denied for user 'my name'@'localhost' to database 'Newdatabase'

 

Do you know why?

 

By the way, which username and password do i use?

 

My server's

or my mysql

username and password - thats y it gave you the access denied error. if you used default settings when setting up your mysql server, username is "root" and password is empty (if you didn't set 1) or the one u set when installing the mysql server.

My sql is provided by the company i am hosting at

 

 

 

I used "root" and No password

 

this is what i got:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/npsari/public_html/trials/connectcreate2.php on line 8

Not done connecting

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/npsari/public_html/trials/connectcreate2.php on line 26

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/npsari/public_html/trials/connectcreate2.php on line 26

Access denied for user 'nobody'@'localhost' (using password: NO)

 

Does that mean anything?

 

An this is the code I used:

 

 

<?php

$con = mysql_connect("localhost","root","");


if ($con) {

      print("Done connecting<BR>\n");

} else {

      print("Not done connecting<BR>\n");
  
}



  
  // connect to server

if (mysql_query('CREATE DATABASE Newdatabase')) {

   echo "success";

} else {

     echo mysql_error();
}



?>

If you're using just standard shared hosting from any number of hosting providers, you likely do not have permissions to create databases through SQL.  Most probably you have to add the database and user through whatever control panel interface your webhost provides, or if they don't, send them a request asking for it to be created.

My sql is provided by the company i am hosting at

 

 

 

I used "root" and No password

 

this is what i got:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/npsari/public_html/trials/connectcreate2.php on line 8

Not done connecting

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/npsari/public_html/trials/connectcreate2.php on line 26

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/npsari/public_html/trials/connectcreate2.php on line 26

Access denied for user 'nobody'@'localhost' (using password: NO)

 

Does that mean anything?

 

An this is the code I used:

 

 

<?php

$con = mysql_connect("localhost","root","");


if ($con) {

      print("Done connecting<BR>\n");

} else {

      print("Not done connecting<BR>\n");
  
}



  
  // connect to server

if (mysql_query('CREATE DATABASE Newdatabase')) {

   echo "success";

} else {

     echo mysql_error();
}



?>

 

 

if u gave space b/w the two double quotes  then the password is "no". so try it by deleting the space .

 

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.