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
https://forums.phpfreaks.com/topic/78429-allowed-memory-size-exhausted/
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

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'];

 

 

this is very strange it should work without any problem maybe other gurus on the site could help although am looking into the code

 

why don't you just try printing

 

echo $row['ucpf_compulsory'];

 

instead of the print 1 maybe there some problem with the fetching

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.