validating CSV before saving in MYSQL

Reply

Join Date: Dec 2006
Posts: 34
Reputation: php_coder is an unknown quantity at this point 
Solved Threads: 0
php_coder php_coder is offline Offline
Light Poster

validating CSV before saving in MYSQL

 
0
  #1
Dec 15th, 2006
hi all
could someone plz help me out in validating csv file(excel sheet) before i can insert it into the database?
i hv the code for uploading but not validating
reply ASAP.
cheers
coder
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: validating CSV before saving in MYSQL

 
0
  #2
Dec 15th, 2006
Ok, here's a hint: CSV files are normally just plain text. You have to read the information in before you can do anything with it.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 23
Reputation: DennisP is an unknown quantity at this point 
Solved Threads: 0
DennisP DennisP is offline Offline
Newbie Poster

Re: validating CSV before saving in MYSQL

 
0
  #3
Dec 16th, 2006
http://codewalkers.com/seecode/585.html

If you're lazy like me.
Simple PHP Pagination - No Database Required.
If you like it, give me some props. ;)
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 34
Reputation: php_coder is an unknown quantity at this point 
Solved Threads: 0
php_coder php_coder is offline Offline
Light Poster

Re: validating CSV before saving in MYSQL

 
0
  #4
Dec 18th, 2006
Originally Posted by DennisP View Post
http://codewalkers.com/seecode/585.html

If you're lazy like me.
Hi
thanks for the reply. But i hv already done what you hv sent me....
my csv contains firstname,lastname,email id. So i have to validate the
email and not allow specialchar other than @. The following is my code.....
if($_REQUEST['submit'])
{
$errmsg="";
$contents = file ('./email_entries.csv');
for($i=0; $i<sizeof($contents); $i++)
{
$line = trim($contents[$i],'",$#!%&^*()');
$arr = explode(',', $line);

if(!$arr)
{
$errmsg.='Invalid CSV file! Please check again.';
}
else{
$sql = mysql_query("insert into employees(first_name,last_name,email_id) values ('".$arr[0]."','".$arr[1]."','".$arr[2]."')");
}

}
}
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 2
Reputation: morecambe is an unknown quantity at this point 
Solved Threads: 0
morecambe morecambe is offline Offline
Newbie Poster

Re: validating CSV before saving in MYSQL

 
0
  #5
Apr 6th, 2009
PHP_CODER did you finish your project and learn how to validate the csv contents. I'm exactly at the point where you were when you asked your qustion. If you did find out how to do the validation please can you post the answer.

Thx
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: validating CSV before saving in MYSQL

 
0
  #6
Apr 6th, 2009
see this link. may be it can help you

http://www.bigresource.com/PHP-CSV-f...-hYLSnyxf.html
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 2
Reputation: morecambe is an unknown quantity at this point 
Solved Threads: 0
morecambe morecambe is offline Offline
Newbie Poster

Re: validating CSV before saving in MYSQL

 
0
  #7
Apr 6th, 2009
Originally Posted by BzzBee View Post
see this link. may be it can help you

http://www.bigresource.com/PHP-CSV-f...-hYLSnyxf.html

Thanks for your message but I already saw that link - it's actually useless - it just takes me to another forum here with half a reply:
http://www.phpfreaks.com/forums/index.php?topic=158173
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2780 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC