Jump to content

Allowed memory size exhausted?


Perad

Recommended Posts

I have 2 arrays... one works and one doesn't. The first one brings about this error.

 

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes) in /Applications/xampp/xamppfiles/htdocs/minisite/scripts/user_cp/register.php on line 145

 

$sql = "SELECT * FROM ucp_fields";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$upcf_data[] = array("ucpf_name" => $row['ucpf_name'], "ucpf_compulsory" => $row['ucpf_compulsory']	);
}

 

This one has no error. From what I can tell they are both identical...

 

$sql = "SELECT * FROM ucp_fields";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
if ($row['ucpf_compulsory'] == 1) {
	$ucp_forms_compulsory[] = array(
           		"ucpf_name" => $row['ucpf_name'],
		"ucpf_maxlength" => $row['ucpf_maxlength'],
		"ucpf_type" => $row['ucpf_type'],
		"ucpf_register_values" => $row['ucpf_register_values']
	);
} 
}

 

Help finding what is causing this would be very very welcome

Link to comment
Share on other sites

well its hard to tell just with that one line maybe your $upcf_data is already has some data in it I always would do

 

$sql = "SELECT * FROM ucp_fields";
$result = mysql_query($sql);
$upcf_data = array();
while ($row = mysql_fetch_assoc($result)) {
$upcf_data[] = array("ucpf_name" => $row['ucpf_name'], "ucpf_compulsory" => $row['ucpf_compulsory']	);
}

 

before using any array in my code

Link to comment
Share on other sites

That doesn't work..

 

On closer inspection...

 

$upcf_data[] = array(
      "ucpf_compulsory" => $row['ucpf_compulsory']
);

 

Doesn't work. This does

 

$upcf_data[] = array(
"ucpf_name" => $row['ucpf_name']
);

 

However the code below works fine.

 

print $row['ucpf_compulsory'];

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.