/    Sign up×
Community /Pin to ProfileBookmark

Memory error. Please help

Greetings, I am receiving the following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /Users/Greg/Sites/homework2.php on line 112

Here is the code for the program ( I have marked line 112)

[CODE]<?php

echo “<html>n

<head>n

<title>Translation, first reading frame</title>

</head>n” ;

echo “<body>” ;

echo “<h1><b>Amino acid translation, frame 1</h1>” ;

// Code for translating nucleic acid sequence into amino acids

$translater = array(

“TCA” => “S”, // SERINE

“TCC” => “S”, // SERINE

“TCG” => “S”, // SERINE

“TCT” => “S”, // SERINE

“TTC” => “F”, // PHENYLALANINE

“TTT” => “F”, // PHENYLALANINE

“TTA” => “L”, // LEUCINE

“TTG” => “L”, // LEUCINE

“TAC” => “Y”, // TYROSINE

“TAT” => “Y”, // TYROSINE

“TAA” => “-“, // STOP

“TAG” => “-“, // STOP

“TGC” => “C”, // CYSTEINE

“TGT” => “C”, // CYSTEINE

“TGA” => “-“, // STOP

“TGG” => “W”, // TRYPTOPHAN

“CTA” => “L”, // LEUCINE

“CTC” => “L”, // LEUCINE

“CTT” => “L”, // LEUCINE

“CTG” => “L”, // LEUCINE

“CCA” => “P”, // PROLINE

“CCC” => “P”, // PROLINE

“CCG” => “P”, // PROLINE

“CCT” => “P”, // PROLINE

“CAC” => “H”, // HISTIDINE

“CAT” => “H”, // HISTIDINE

“CAA” => “Q”, // GLUTAMINE

“CAG” => “Q”, // GLUTAMINE

“CGA” => “R”, // ARGININE

“CGC” => “R”, // ARGININE

“CGG” => “R”, // ARGININE

“CGT” => “R”, // ARGININE

“ATA” => “I”, // ISOLEUCINE

“ATC” => “I”, // ISOLEUCINE

“ATT” => “I”, // ISOLEUCINE

“ATG” => “M”, // METHIONINE

“ACA” => “T”, // THREONINE

“ACC” => “T”, // THREONINE

“ACG” => “T”, // THREONINE

“ACT” => “T”, // THREONINE

“AAC” => “N”, // ASPARAGINE

“AAT” => “N”, // ASPARAGINE

“AAA” => “K”, // LYSINE

“AAG” => “K”, // LYSINE

“AGC” => “S”, // SERINE

“AGT” => “S”, // SERINE

“AGA” => “R”, // ARGININE

“AGG” => “R”, // ARGININE

“GTA” => “V”, // VALINE

“GTC” => “V”, // VALINE

“GTG” => “V”, // VALINE

“GTT” => “V”, // VALINE

“GCA” => “A”, // ALANINE

“GCC” => “A”, // ALANINE

“GCG” => “A”, // ALANINE

“GCT” => “A”, // ALANINE

“GAC” => “D”, // ASPARTIC ACID

“GAT” => “D”, // ASPARTIC ACID

“GAA” => “E”, // GLUTAMIC ACID

“GAG” => “E”, // GLUTAMIC ACID

“GGA” => “G”, // GLYCINE

“GGC” => “G”, // GLYCINE

“GGT” => “G”, // GLYCINE

“GGG” => “G”, // GLYCINE

);

$input = $_POST[‘INPUT’] ;

// Chomp off newline

$data = rtrim($input) ;

// Get length and convert to uppercase

$rawSequence = strtoupper($data) ;

$seqLength = strlen($rawSequence) ;

$x = 0 ;

// Convert string to array

$sequence = str_split($rawSequence,1) ;

for($i = 0 ; $i<($seqLength-2) ; $i+3)

{

$firstLetter = $sequence[$i] ;

$secondLetter = $sequence[$i+1] ;

$thirdLetter = $sequence[$i+2] ;

$codon = $firstLetter.$secondLetter.$thirdLetter ;

$polyPeptide[$x] = $translater[“$codon”] ; // <—- [B]LINE 112 !!!!![/B]

$x++ ;

}

// echo $_POST[‘INPUT’] ; // Test to see if data transfers

?>[/CODE]

I new to php and not sure how to initialize an empty array.

any help would be great

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 21.2008 — You are not incrementing your loop counter, as you need it to be "+=" instead of "+":
<i>
</i>for ($i = 0; $i &lt; ($seqLength-2); $i+[B][COLOR="red"]=[/COLOR][/B]3)
×

Success!

Help @TheDragonReborn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...