Re: Notice

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

 



Hi Ricardo,

Thanks!

I figured it out last night the entries on the database were incomplete, so that makes perfect sense with what you are saying. Ir also occurred to me that this is something that may happen in the real application, so here is my next question: is there a way an can catch those errors and use say javascript to display them?

Thanks!

T.

On Mar 27, 2014, at 12:14 AM, Ricardo R Bonfim <ricobonfim@xxxxxxxxx> wrote:

> Hi Tiago,
> 
> *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*
> 
> These two, as I think, were raised because of lines below. You tried
> to access $data array on $loci position, what i'm guessing that is
> probably inexistent on this array. I suggest you to see what values do
> you have on $snp array and compare to $row[6] to see if they match
> each other.
>                $alelleY = $data[$ids][$loci]['alelleY'];
>                $alelleX = $data[$ids][$loci]['alelleX'];
> 
> 
> *Notice*: Array to string conversion in
> */Applications/MAMP/htdocs/catcnew/snppitv1.php* on line *66*
> 
> The last notice is certainly raised because you are trying to use an
> array as a string on the line below. $role is an array, right? You
> could use explode function to turn each value from $role into a string
> separated by comma for example.
>            $body .= "$ids\t$role\t" . substr($content, 0, -1) . "\n";
> 
> Good luck
> 
> 2014-03-26 20:30 GMT-03:00 Tiago Hori <tiago.hori@xxxxxxxxx>:
>> 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.
>> 
>> 
>> --
>> "Education is not to be used to promote obscurantism." - Theodonius
>> Dobzhansky.
>> 
>> "Gracias a la vida que me ha dado tanto
>> Me ha dado el sonido y el abecedario
>> Con él, las palabras que pienso y declaro
>> Madre, amigo, hermano
>> Y luz alumbrando la ruta del alma del que estoy amando
>> 
>> Gracias a la vida que me ha dado tanto
>> Me ha dado la marcha de mis pies cansados
>> Con ellos anduve ciudades y charcos
>> Playas y desiertos, montañas y llanos
>> Y la casa tuya, tu calle y tu patio"
>> 
>> Violeta Parra - Gracias a la Vida
>> 
>> Tiago S. F. Hori. PhD.
>> Ocean Science Center-Memorial University of Newfoundland
> 
> 
> 
> -- 
> ____________________________________________________
> Ricardo R Bonfim


-- 
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