|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Question
Someone know where i can download php4 script with functions connect to mysql database like CREATE DATABASE,CREATE TABLE,CREATE FIELD and
IMPORT DATAS.I have mysql manual and php manual with mysql commands,but there is just commands for dos,and i need php scripts.I was found something on net,but all that is for php3,and i need for php4.I have phpmyadmin,but he dont want import text files,he report some error type Errot in LOAD DATA LOCA INTO TABLE cannot found c:\apache\php\4324235rfs.tmp Something like that type,and he always founding some other tmp file.Can someone show me an example importing text file into database?I need translate my database of arcticles to mysql,i have that in text file. tnx |
|
#2
|
|||
|
|||
|
Hey Jacob,
Is the text file in the appropriate format? I.e. was it exported from MySQL straight to the text file? If it's in another format from another database, then you will need to make sure that the commands are MySQL specific. With PHPMyAdmin, that error looks like your tmp_upload_dir in HTTPD.CONF is set incorrectly. Try changing it to another directory and make sure that directory has full access (CHMOD 777). As for importing a text file into PHP, just read it in using fopen, and you can either do a batch process, passing the whole thing to MySQL_QUERY, or you can delimt the commands with explode(";", $fileContents) and run each one individually. Message me back if you need PHP code samples. ![]() |
|
#3
|
|||
|
|||
|
aa
Well,i dont know in which format text file need to be.Please,show me script like this:
/* <?php # Copyright (C) 2000 - 2002 Ben Drushell # FILE: example.mysql.php3 $TITLE = "PHP MySQL ACCESS" ?> <HTML> <HEAD> <TITLE><?php echo $TITLE ?></TITLE> </HEAD> <BODY> <CENTER><BIG><B> <?php echo $TITLE ?> <BR><BR> <?php # Open MySQL connection. # Before you can walk through a doorway, you must first open the door... if($myDB = mysql_connect("localhost","youruserid","yourpassword",)) { echo "Connection to MySQL server 'localhost' successful!<br>\n"; } # "localhost" can be replaced with an IP address or a domain name. # If your MySQL server is not using the standard MySQL port, # add a port (example localhost:7777). # $myDB saves the present connection. mysql_select_db("yourdatabasename",$myDB); echo "Database selected<br>\n"; $query = "CREATE TABLE test ("; $query .= "id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,"; $query .= "date DATE);"; if(mysql_query($query,$myDB)) { echo "Table 'test' created<br>\n"; } # $query contains the SQL statements that will be executed by MySQL $query = "INSERT INTO test (id,date) VALUES(NULL,\""; $query .= date("Y-m-d"); $query .= "\");"; if(mysql_query($query,$myDB)) { echo "Insert successful<br>\n"; } # $query contains the SQL statements that will be executed by MySQL $query = "INSERT INTO test (id,date) VALUES(NULL,\""; $query .= date("Y-m-d"); $query .= "\");"; if(mysql_query($query,$myDB)) { echo "Insert successful<br>\n"; } # NULL is required for the id, because it will be inserted automatically. # date command formats a date from current time. # Y indicates a 4-digit year # m indicates a 2-digit month # d indicates a 2-digit day $id = mysql_insert_id(); echo $id . " is the id number.<br>\n"; # mysql_insert_id retrieves the id value generated in the # sql insert statement. # For PHP4 compatibility, leave the contents of the mysql_insert_id # function blank. Adding a database identifier will create an error # in PHP4. $query = "SELECT * FROM test;"; $result = mysql_query($query,$myDB); while($row = mysql_fetch_array($result,1)) { echo "id = " . $row['id'] . "; date = " . $row['date'] . ";<br>\n"; } # This is a very basic search/find statement that loops through the # contents of 'test' table. # $result stores the query affected instance of the database. # mysql_fetch_array retrieves a record. # The "1" option returns an array with real name indexes. # A "2" option will return an array with number indexes. # A "3" option will return an array with both real name and number indexes. # $row stores the array/record. $query = "UPDATE FROM test SET date = \"1995-01-10\" WHERE id = 1;"; if(mysql_query($query,$myDB)) { echo "Record updated;<br>\n"; } $query = "SELECT * FROM test;"; $result = mysql_query($query,$myDB); while($row = mysql_fetch_array($result,1)) { echo "id = " . $row['id'] . "; date = " . $row['date'] . ";<br>\n"; } $query = "DELETE FROM test WHERE id = 1;"; if(mysql_query($query,$myDB)) { echo "Record deleted<br>\n"; } $query = "SELECT * FROM test;"; $result = mysql_query($query,$myDB); while($row = mysql_fetch_array($result,1)) { echo "id = " . $row['id'] . "; date = " . $row['date'] . ";<br>\n"; } $query = "DROP TABLE test;"; if(mysql_query($query,$myDB)) { echo "Table 'test' deleted<br>\n"; } mysql_close($myDB); echo "The MySQL database connection is now closed<br>\n"; # After going through a doorway, you close the door after yourself... # Technically PHP should automatically close the database connection at # the end of the script, but I like to re-emphasize that the connection # is being closed. ?> </B></BIG></CENTER> </BODY> </HTML> */ That script is written in php3,thats whay is not working.I need that script in php4.Also,in which format is text file for importing? And,this is example of my database:Table:Names Number Name Lastname 1 Luke Smith 2 John Hawk 3 Rocky Junior 4 Mike Tyson 5 Jimi Stanic So,i want import over text file informations.I have 3500 arcitles,so only way is import to database over text file.Manualy importing is impossible. Tnx |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|