Welcome to Truecodeing.tk plz join are other site TrueGamerz.tk
Site admin Dirty_Tazer & Bman24 & Snick458 & Always_Jonezen have any questions ask a admin or a mod
Welcome to Truecodeing.tk plz join are other site TrueGamerz.tk
Site admin Dirty_Tazer & Bman24 & Snick458 & Always_Jonezen have any questions ask a admin or a mod
Would you like to react to this message? Create an account in a few clicks or log in to continue.


TrueGamerz.tk
 
HomeHomeGallerySearchLatest imagesRegisterLog in
We have a new site that's a vbulliten join TrueGamerz.Tk
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
Xx...Tazer...xX (1239)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
bman24 (247)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
Always_Jonezen (155)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
Navy-Hawk (121)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
qwerty (91)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
CjZitical (91)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
snick458 (80)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
MAG (77)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
»Air Bourne« (76)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
.-jZeIvIiiX-. (73)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcapCHANGE CSV TO MYSQL - PHP SNIPPET   I_voting_barCHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap 
Latest topics
» Socom FTB3 USA Gamesave 100% Complete
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeSun Dec 29, 2013 7:31 pm by pandemic44

» Making a scantime crypter - VB.net
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeWed Aug 15, 2012 7:01 am by shayl

» VERY IMPORTANT !!!!!!!!!!
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeFri Mar 09, 2012 9:34 pm by kfederigan

» my FTB3 gamesave request
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeTue Oct 25, 2011 2:39 pm by The.S.Man

» How To Install Pspsdk (PRX Compiler)
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeThu Aug 04, 2011 3:47 pm by xUnD3ADxMARIN3x

» Hope's
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeFri Jul 15, 2011 3:51 pm by nemopsp

» Offline Guns Online No Need Gamesaves!
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeWed Apr 20, 2011 3:08 pm by jeshuag

» Need Game Save Please
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeMon Apr 18, 2011 8:15 am by guy mandude

» my gsave request
CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeSun Apr 10, 2011 12:57 pm by Killin

Who is online?
In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests

None

Most users ever online was 120 on Tue May 14, 2019 3:05 pm
Statistics
We have 826 registered users
The newest registered user is netanter

Our users have posted a total of 3902 messages in 2169 subjects
Poll
Do you like too shop online??
Yes
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcap25%CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap
 25% [ 14 ]
no
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcap25%CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap
 25% [ 14 ]
Don't have credit card
CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_lcap51%CHANGE CSV TO MYSQL - PHP SNIPPET   I_vote_rcap
 51% [ 29 ]
Total Votes : 57
HITS
HTML Hit Counter
Web Counter
facebook
truecodeing

truecodeing

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
May 2024
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031 
CalendarCalendar
Search
 
 

Display results as :
 
Rechercher Advanced Search
Affiliates
 
Social bookmarking
Social bookmarking reddit      

Bookmark and share the address of Truecodeing on your social bookmarking website

Bookmark and share the address of on your social bookmarking website
Music playlist

MusicPlaylist
Music Playlist at MixPod.com

 

 CHANGE CSV TO MYSQL - PHP SNIPPET

Go down 
AuthorMessage
Xx...Tazer...xX
Owner
Owner
Xx...Tazer...xX


Posts : 1239
T®ue Points : 1102678
T®ue Reputation : 40
Join date : 2009-09-02
Age : 31
Location : Chicago,Illinois

CHANGE CSV TO MYSQL - PHP SNIPPET   Empty
PostSubject: CHANGE CSV TO MYSQL - PHP SNIPPET    CHANGE CSV TO MYSQL - PHP SNIPPET   I_icon_minitimeSun Jul 11, 2010 7:28 pm

today I will you guys a snippet of changing CSV to MySQL. This snippet takes the contents from a CSV file and insert it into a MySQL database table. In this part of the topic, I will post all of the directions needed in order to know this procedure. If you had any problems, please contact me and I will be gladly to help, also you can review in my Quick References of advanced/Basic PHP for any trouble. Here are the following instructions or directions.

Instructions of Functions of parameters:
Additional directions will be added right next to this symbol---> "//" as a sentence.

The function to import a CSV file into a MySQL table. The function expects 7 parameters, so here are the following:

$file = The file to open.
$delimiter = What the file is delimited with.
$host = Host of the database.
$dbname = Name of the database we're using.
$username = The databases username.
$password = Users password.
$table = Name of the table we're inserting into.

Ok here is the the source file:

CSV to MySQL source file

Code: [Select]
function CsvToSql($file, $delimiter, $host, $dbname, $username, $password, $table)
{
//first connection to our database
$conn = mysql_connect($host, $username, $password) or die();
//select our database
mysql_select_db($dbname);

//make sure the file exists
if(!file_exist($file)
{
echo 'The file name '.$file.' does not exist';
}
else
{
$data = fopen($file, "r");

//now make sure the open worked
if(!$data)
{
'The file was empty';
}

//read the contents of the file int the $contents variable
$contents = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

//now close the file since we have it's contents
fclose($file);


//start a loop
for($i = 0 ; $i < $size; i++)
{
//get the current line
$line = trim($contents[$i], $delimiter);

$split = explode($delimiter, $line);

$import = "INSERT INTO ". $table . " values('" . implode("','", $split) . "')";

if(!mysql_query($import))
echo_mysql_error();
}

}

mysql_close($conn);
}
Back to top Go down
https://truecodeing.forumotion.net
 
CHANGE CSV TO MYSQL - PHP SNIPPET
Back to top 
Page 1 of 1
 Similar topics
-
» MYSQL CONNECT INSTRUCTIONS AND ERRORS - PHP

Permissions in this forum:You cannot reply to topics in this forum
 :: Computer section :: Visual basic :: PHP-
Jump to:  
Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com