Jump to content
tinfanide

Create Database (How To Create A Database Using Codes?)

Recommended Posts

This is my php file:

<?php$connect = mysql_connect("localhost","root","") or die(mysql_error());if(is_resource($connect)){echo "Connected";} else {  echo "Not yet connected";  }$myDatabase = "CREATE DATABASE myDatabase";mysql_query($myDatabase,$connect);mysql_select_db("myDatabase",$connect);$myDatabase_table = "CREATE TABLE myTable (id,name,email,PRIMARY KEY(id))";?>

I'm using phpmyadmin and would like to create a SQL database completely through typing codes.But it does not work. I've searched the net for solutions but few of them created databases through typing codes.Some are using MySQL.exe but can I just do it on Notepad instead of, say, creating it in the phpmyadmin interface?

Share this post


Link to post
Share on other sites

Yes, thanks for directing me to the tutorial.Actually I've read that before, but just missed some important codes.

if(mysql_query())mysql_close();varchar()

which may, I reckon, produce the error result.

Share this post


Link to post
Share on other sites

By the way, lots of hosts don't give you CREATE DATABASE permissions, which might also be a problem.

Share this post


Link to post
Share on other sites

Yes, I'll discover it as long as my experiences in SQL grow. Now I'm just working on the very little part of the server stuff.It may be true that using the SQL interface to set up database or table is more stable than scripting SQL, right?

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...