aconite Posted February 27, 2007 Share Posted February 27, 2007 i have a real wierd prob :'( i have one file working.php which creates a database, selects it and then creates a table.another file drop.php drop that particular database. first when i executed the working.php file, the database and table were created.then i dropped the database using drop.php. then i made a few changes in working.php to create two more table. but now the same file wont give any output. i am viewing the files in internet explorer.it gives absolutly no output. ???running drop.php gives the error Error dropping database: Can't drop database 'mydatabase'; database doesn't exist it makes sense since working.php is not working but wht should i do working.php <?php $con = mysql_connect("127.0.0.1","root","12345"); if (!$con) { echo "Could not connect: ' . mysql_error(); } if (mysql_query("CREATE DATABASE mydatabase",$con)) { echo 'Database created '; } else { echo "Error creating database: " . mysql_error(); } if(!mysql_select_db("mydatabase")) { die('Could not select database: mydatabase ' . mysql_error()); } echo "Database selected "; if (mysql_query("CREATE TABLE customer (f_name VARCHAR(15) NOT NULL, l_name VARCHAR(15) NOT NULL, phone VARCHAR(11) , account INT UNSIGNED PRIMARY KEY)") ) { echo 'table created'; } else { echo " Error creating table customer: " . mysql_error(); } if (mysql_query("CREATE TABLE account (account2 INT(7) UNSIGNED PRIMARY KEY, password VARCHAR(4) NOT NULL, balance FLOAT(3) , valid_till DATE YYYY-MM-DD)") ) { echo "created account table"; } else { echo "account nt created " .mysql_error(); } if (mysql_query("CREATE TABLE Transaction (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, source INT(7) UNSIGNED, destination INT(7) UNSIGNED, amount INT(3) NOT NULL, date DATE YYYY-MM-DD, strt_time TIME 00:00:00, end_time TIME 00:00:00 , status ENUM("TRUE","FALSE") NOT NULL)") ) { echo("created transaction table"; } else { echo "tran nt created " .mysql_error(); } ?> drop.php <?php $con = mysql_connect("127.0.0.1","root","12345"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo '1 '; if (mysql_query("DROP DATABASE mydatabase",$con)) { echo 'Database dropped '; } else { echo "Error dropping database: " . mysql_error(); } mysql_close($con); ?> any idea what to do?im completely new and now lost Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/ Share on other sites More sharing options...
fenway Posted February 27, 2007 Share Posted February 27, 2007 Hard to say... make sure you can get the php script to run with just a basic connecion script. Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-195489 Share on other sites More sharing options...
aconite Posted February 27, 2007 Author Share Posted February 27, 2007 i executed this code <?php echo '1 '; $con = mysql_connect("127.0.0.1:3306","root","12345"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo '1 '; ?> gives the output 1 1 so a simple connection works fine.but still ahving problem with the working.php file ??? Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-195517 Share on other sites More sharing options...
fenway Posted February 27, 2007 Share Posted February 27, 2007 Then bring back each piece of the code, one block at a time. Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-195530 Share on other sites More sharing options...
aconite Posted February 28, 2007 Author Share Posted February 28, 2007 i pasted each block ,one by one.first two tables are created successfully the prob is in if (mysql_query("CREATE TABLE transaction (id INT(4) AUTO_INCREMENT NOT NULL PRIMARY KEY, source INT(7) UNSIGNED, destination INT(7) UNSIGNED, amount INT(3) NOT NULL, date DATE , strt_time TIME , end_time TIME , status ENUM("TRUE","FALSE") NOT NULL)") ) { echo("created transaction table"; } else { echo "-tran nt created- " .mysql_error(); } when i include this block of code no output is given ??? Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-195818 Share on other sites More sharing options...
aconite Posted February 28, 2007 Author Share Posted February 28, 2007 problem solved!!! the solution was if (mysql_query("CREATE TABLE transaction (id INT(4) AUTO_INCREMENT NOT NULL PRIMARY KEY, source INT(7) UNSIGNED, destination INT(7) UNSIGNED, amount INT(3) NOT NULL, date DATE , strt_time TIME , end_time TIME , status ENUM(\"TRUE\",\"FALSE\") NOT NULL)") ) Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-195898 Share on other sites More sharing options...
fenway Posted February 28, 2007 Share Posted February 28, 2007 Of course, the quoting -- if you used single quotes for your enum list, you wouldn't have this problem. Quote Link to comment https://forums.phpfreaks.com/topic/40400-solved-multiple-tables-in-one-php-file/#findComment-196030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.