943,929 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4861
  • PHP RSS
Dec 15th, 2006
0

validating CSV before saving in MYSQL

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
php_coder is offline Offline
34 posts
since Dec 2006
Dec 15th, 2006
0

Re: validating CSV before saving in MYSQL

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.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004
Dec 16th, 2006
0

Re: validating CSV before saving in MYSQL

http://codewalkers.com/seecode/585.html

If you're lazy like me.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DennisP is offline Offline
23 posts
since Sep 2006
Dec 18th, 2006
0

Re: validating CSV before saving in MYSQL

Click to Expand / Collapse  Quote originally posted by DennisP ...
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]."')");
}

}
}
Reputation Points: 10
Solved Threads: 0
Light Poster
php_coder is offline Offline
34 posts
since Dec 2006
Apr 6th, 2009
0

Re: validating CSV before saving in MYSQL

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
morecambe is offline Offline
2 posts
since Apr 2009
Apr 6th, 2009
0

Re: validating CSV before saving in MYSQL

see this link. may be it can help you

http://www.bigresource.com/PHP-CSV-f...-hYLSnyxf.html
Reputation Points: 16
Solved Threads: 48
Posting Whiz
BzzBee is offline Offline
327 posts
since Apr 2009
Apr 6th, 2009
0

Re: validating CSV before saving in MYSQL

Click to Expand / Collapse  Quote originally posted by BzzBee ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
morecambe is offline Offline
2 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Calling PHP function Onchange on Javascript
Next Thread in PHP Forum Timeline: Hi everyone....High Dr. Nick





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC