tinfanide Posted November 3, 2011 Share Posted November 3, 2011 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 More sharing options...
aspnetguy Posted November 3, 2011 Share Posted November 3, 2011 Check out this tutorial. It should work.http://www.w3schools.com/php/php_mysql_create.asp Link to comment Share on other sites More sharing options...
tinfanide Posted November 3, 2011 Author Share Posted November 3, 2011 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 More sharing options...
Synook Posted November 4, 2011 Share Posted November 4, 2011 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 More sharing options...
tinfanide Posted November 4, 2011 Author Share Posted November 4, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.