hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Contents of textfile into mysql
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Contents of textfile into mysql

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2005, 03:03 PM
mjfroggy mjfroggy is online now
Web Hosting Master
 
Join Date: Feb 2002
Location: New York
Posts: 741

Contents of textfile into mysql


I have a friend who has a music site and gets a textfile ever month with new music/artists. what I want to do is extract all the song titles and insert them into a song title field in a mysql database and extract all the artist's and insert them into a artist field in a mysql database

is this possible? If so how? I can get the file in MSword or text file format.

The text file looks like this

Song title
track
length
artist
cd title

This I promise you
1
04:44
*N Sync - NMT
volume 51
Music of My Heart
2
04:31
*N Sync - (feat. Gloria Estefan)
volume 26
Cherry Bomb

Reply With Quote


Sponsored Links
  #2  
Old 01-16-2005, 03:52 PM
ilyash ilyash is offline
Web Hosting Master
 
Join Date: Dec 2002
Location: NY, NY
Posts: 3,975
write a quick script that parses the file, and puts it into sql format.
them mysqldump it...

Reply With Quote
  #3  
Old 01-16-2005, 04:01 PM
mjfroggy mjfroggy is online now
Web Hosting Master
 
Join Date: Feb 2002
Location: New York
Posts: 741
re:

know of any code snippets or scripts on the web I can use.

thanks

Reply With Quote
Sponsored Links
  #4  
Old 01-16-2005, 08:53 PM
mjfroggy mjfroggy is online now
Web Hosting Master
 
Join Date: Feb 2002
Location: New York
Posts: 741
re:

OK I am going to manually enter in the info I need to the mysql. I have a form that lets me enter in multiple rows worth of data. My problem is my process.php file is not working.
Any idea why? it is suppose to insert muliple rows into my mysql

thanks for help

insert multiple rows
<?php

// Define Variables
$title[0] = $_POST['title1']; // Change the 'title1' to the id of the input box
$title[1] = $_POST['title2'];
$title[2] = $_POST['title3'];
$title[3] = $_POST['title4'];
$title[4] = $_POST['title5'];
$artist[0] = $_POST['artist1'];
$artist[1] = $_POST['artist2'];
$artist[2] = $_POST['artist3'];
$artist[3] = $_POST['artist4'];
$artist[4] = $_POST['artist5'];
$cd[0] = $_POST['cd1'];
$cd[1] = $_POST['cd2'];
$cd[2] = $_POST['cd3'];
$cd[3] = $_POST['cd4'];
$cd[4] = $_POST['cd5'];
$track[0] = $_POST['track1'];
$track[1] = $_POST['track2'];
$track[2] = $_POST['track3'];
$track[3] = $_POST['track4'];
$track[4] = $_POST['track5'];
$length[0] = $_POST['length1'];
$length[1] = $_POST['length2'];
$length[2] = $_POST['length3'];
$length[3] = $_POST['length4'];
$length[4] = $_POST['length5'];
$limit_num = 5; // Number of times the loop will run, make sure the array has 5 values as well or else you will insert blank

rows
$host = "localhost";
$user = "*****";
$password = "*****";
$database = "*****";

// Connect to Database
$connection = mysql_connect($host,$user,$password); // Connect
$select_db = mysql_select_db($database,$connection); // Select DB

for ($z=0; $z<$limit_num; $z++) {
$current_qual = "$title[$z],$artist[$z],$cd[$z],$track[$z],$length[$z]"; // Sets value to the current qual
$query = "INSERT INTO music VALUES ('$current_qual')"; // Query
$result = mysql_query($result,$connection); // Execute
}

?>

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Parallels Now Offering Licenses for CloudLinux OS Web Hosting News 2011-10-26 17:29:25
Web Hosting Sales and Promos Roundup - October 7, 2011 Web Hosting News 2011-10-07 19:56:18
Web Hosting Software Firm CloudLinux Releases CloudLinux OS Version 6.1 Web Hosting News 2011-09-13 14:08:49
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?