m31hu1 Posted October 21, 2006 Share Posted October 21, 2006 Hi all, I'm new to this forum... and need help regarding a project that i am doing.I'm trying to let sql store data from a text file, but the data won't display...what am i missing here? Your help is greatly appreciated.create table<?php$con = mysql_connect("localhost","root","password");if (!$con){die('Could not connect: ' . mysql_error());}// Create databaseif (mysql_query("CREATE DATABASE bulkdb",$con)){echo "Database created";}else{echo "Error creating database: " . mysql_error();}// Create table in bulkdb databasemysql_select_db("bulkdb", $con);$sql = "CREATE TABLE Bulktable(fileID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(fileID),FileName varchar(15),Directory varchar(100))";mysql_query($sql,$con);?>bulk insert<?php$con = mysql_connect("localhost","root","password");if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("bulkdb", $con);$bulkinsert = "BULK INSERT BulktableFROM 'test.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' )";if ($bulkinsert){echo "inserted";}else{echo "not inserted";}mysql_close($con);?>bulk select<?php$con = mysql_connect("localhost","root","password");if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("bulkdb", $con);$result = mysql_query("SELECT * FROM bulktable"); mysql_close($con);echo "<table><tr><th colspan=\"3\">Results</th></tr><tr>";while($row = mysql_fetch_array($result)){$img = $row['Directory'] . "" . $row['FileName'];echo "<td><img src=\"$img\" height=\"60\" width=\"60\"></td>";}?>test.txt1.jpg,http://localhost/images/2.jpg,http://localhost/images/3.jpg,http://localhost/images/4.jpg,http://localhost/images/5.jpg,http://localhost/images/6.jpg,http://localhost/images/7.jpg,http://localhost/images/8.jpg,http://localhost/images/Regards,Mei Hui Quote Link to comment Share on other sites More sharing options...
fert Posted October 21, 2006 Share Posted October 21, 2006 you can't create a Database with mysql_query Quote Link to comment 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.