Re: Notice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please don't send to my direct email.  I read the forums regularly enough.

On 3/26/2014 7:30 PM, Tiago Hori wrote:
Hi Everyone,

I am at loss so I am hoping your wisdom can help me.

I originally had a script that first got a list of terms to be searched
from the file uploaded in the first part. This list is stored in the array
$snp. Every item in $snp occurs once for every entry i have in the table.
The goal is to allow the user to select a set in the file uploaded and get
every entry for a given project, which is entered via POST.

I had originally wrote this in way that it made 3 or 4 calls to the
database and it was way to slow, so I tried to make one call to the
database and put everything in a multidimensional array.

Now, what I have below seems to work, but I get 3notices for every
iteration of the foreach($rows as $ids) and I can't figure out for the life
of me why.

*Notice*: Undefined index: in
*/Applications/MAMP/htdocs/catcnew/snppitv1.php* on line *62*

*Notice*: Undefined index: in
*/Applications/MAMP/htdocs/catcnew/snppitv1.php* on line *63*

*Notice*: Array to string conversion in
*/Applications/MAMP/htdocs/catcnew/snppitv1.php* on line *66*


I guess I would like to know what it is going on out of curiosity and if it
can cause a problem down the road. Also, any suggestions on improvement are
always welcome.

if(isset($_FILES['snps']))
{
     $dir = 'uploads';
     $header = "role\t";
     $filename = $_FILES['snps']['name'];
     if (file_exists("$dir/$filename"))
     {
         die ("A file with this name already exists in the database <br />");
     }
     else
     {
         move_uploaded_file($_FILES['snps']['tmp_name'], "$dir/$filename");
         echo "Uploaded file '$filename' <br />";
         $fh = fopen("$dir/$filename", 'r') or
             die("File does not exist or you lack permission to open it");
     }
     while (!feof($fh))
     {

         $line = fgets($fh);
         $snp[] = trim(preg_replace('/\n/', '', $line));

     }
     foreach ($snp as $loci)
     {
         $header .= $loci . "\t" . $loci . "\t";
     }

}

if(isset($_POST['project']))
{
     $project = sanitizeStrings($_POST['project']);
     $body =  "";

     $query = "SELECT * FROM genotyped WHERE projectid='$project'";
     $result = queryMysql($query);
     if(mysqli_num_rows($result))
     {
         $data = array();
         while($row = mysqli_fetch_row($result))
         {

             $rows[] = $row[2];
             $role[$row[2]] = $row[3];
             $data[$row[2]][$row[6]]['alelleY'] = $row[7];
             $data[$row[2]][$row[6]]['alelleX'] = $row[8];
         }
         $rows = array_unique($rows);
         foreach($rows as $ids)
         {
             $col2 = $role[$ids];
             $alelleX = $alelleY = $content = "";
             foreach($snp as $loci)
             {
                 $alelleY = $data[$ids][$loci]['alelleY'];
                 $alelleX = $data[$ids][$loci]['alelleX'];
                 $content .= "$alelleY\t$alelleX\t";
             }
             $body .= "$ids\t$role\t" . substr($content, 0, -1) . "\n";
         }
     }
}

unlink("$dir/$filename");


?>

T.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux