| | |
validating CSV before saving in MYSQL
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2004
Posts: 494
Reputation:
Solved Threads: 21
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.
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.
•
•
Join Date: Sep 2006
Posts: 23
Reputation:
Solved Threads: 0
Simple PHP Pagination - No Database Required.
If you like it, give me some props. ;)
If you like it, give me some props. ;)
•
•
Join Date: Dec 2006
Posts: 34
Reputation:
Solved Threads: 0
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]."')");
}
}
}
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]."')");
}
}
}
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
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
![]() |
Similar Threads
- read second line or record of csv file (PHP)
- insert csv file into mysql through php (PHP)
- Websites content extraction team (Post your Resume)
- problem opening CSV file (C++)
- coldfusion administrator error (ColdFusion)
- Save a text file in an csv.file with ascii? (PHP)
Other Threads in the PHP Forum
- Previous Thread: Calling PHP function Onchange on Javascript
- Next Thread: Hi everyone....High Dr. Nick
Views: 2780 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database dataentry date directory display download dynamic echo email error file files firstoptioninphpdroplist folder form forms freelancing function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial tutorials update updates upload url validation validator variable video web white xml youtube





