Jump to content

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


tinfanide

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?

Link to comment
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.

Link to comment
Share on other sites

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

Link to comment
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?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...