ErcFrtz Posted October 29, 2009 Share Posted October 29, 2009 Hello all. I am trying to read a tab delimited text file and update fields in an SQL table using the info from the file, but the php script isn't reading the file correctly. Do I have something incorrect in my code? <?php $uploadFile = "directory_to_my_file"; $readFile = file($uploadFile); foreach($readFile as $line) { $tmp = explode("\t",$line); $markername = $tmp[0]; $ncbissnum = $tmp[1]; $sql = "SELECT * FROM Marker WHERE MarkerName = '$markername'"; $query = mysql_query($sql, $connect) or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { extract($row); if($row["MarkerName"] == $markername) { $sql2 = "UPDATE Marker SET NCBISSNum='$ncbissnum' WHERE MarkerName='$markername'"; $query2 = mysql_query($sql2, $connect) or die(mysql_error()); $result2 = mysql_fetch_array($query2); } } } ?> Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 try echo $line; print_r($tmp); exit; after exploding it, you may need to check what your getting and paste it here Quote Link to comment Share on other sites More sharing options...
ErcFrtz Posted October 29, 2009 Author Share Posted October 29, 2009 Putting that code in doesn't print anything. I had tried echo $line; before but it doesn't print anything. It seems like the file isn't being read properly and I've rechecked my directory info etc and it's correct which is why I asked if I had a coding problem. Is there a possibility the file is too big? Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 try error_reporting(2047); //right ta the top //inside the loop echo $line; print_r($tmp); die(); have you looked at teh page source to make syure its not outing anything ? Quote Link to comment Share on other sites More sharing options...
ErcFrtz Posted October 29, 2009 Author Share Posted October 29, 2009 The page source and the the actual page are both blank. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 The page source and the the actual page are both blank. can you output any php output anywhere else in your system, i mean is there any includes in this file above this ? if not your serve ris messed up Quote Link to comment Share on other sites More sharing options...
ErcFrtz Posted October 29, 2009 Author Share Posted October 29, 2009 There is authentication code for being logged in also in this script before that which I've listed and everything works right up to the $readFile = file($uploadFile); line. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 can ytou echo before $readFile = file($uploadFile); what version php you using turn error_reporting on Quote Link to comment Share on other sites More sharing options...
ErcFrtz Posted October 29, 2009 Author Share Posted October 29, 2009 I solved the problem I was having a different way. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.