hi,
i am struck up at some position.
i\'m assigned a work to get contents form text file & save in db .the format of text file is
bobby a1
bob a2
xxx a3
2 fileds in db.
i have treid something with the explode function .but it is saving part of the string available in text file & irregular format.plz help me.the code is :
<?php
$aryinput=file(\"/var/www/html/prasadwork/dbtxt.txt\",\"r\");
$user=\"root\";
$pwd=\"\";
$db=test;
$dbh=mysql_connect(\"localhost\",$user,$pwd);
if(!dbh)
print \"can\'t connect to the db\";
print \"connected to db\";
mysql_select_db($db)
or die(\"couldn\'t open db:\".mysql_error());
print \"sucessfully selected db:\\"$db\\"<P>\";
print count($aryinput);
for ($i=0;$i<count($aryinput);$i++){
$aryinputline=explode(\" \",$aryinputline[$i]);
$name=$aryinputline[$i];
$id=$aryinputline[$i];
echo $name;
echo $id;
$intotable=mysql_query(\"insert into testtab2 values(\'$name\',\'$id\')\",$dbh);
}
?>
the format it is storing in db is
name id
bobby a1 bobb
bob a2 bo
xxx a3 xx
plz help me.
waiting for response. plz mail me if u can
my mail id is tn_prasad@rediffmail.com
prasad