Deepzone Posted March 16, 2013 Share Posted March 16, 2013 I have the following code the lookup data from a database. It runs okay on my llocal machine but it give me "Fatal error: Allowed memory size of 33554432 bytes exhausted" whenit runs on hosting server. It indicates fatal error at line of $r[field3]); I googled the error and found the response for similar situation is to re-code to prevent memory leak. Can anyone point out how the following can be improve to prevent the error from happening. Thanks a lot. $stmt = $database_connection->stmt_init(); if ($stmt->prepare("SELECT keyA, field1, field2, field3 FROM tableA JOIN tableB ON tableA.field1 = tableB.keyB JOIN tableC ON tableA.field2 = tableC.keyC WHERE field3 LIKE ?")) { $stmt->bind_param('s', $likeString); $stmt->bind_result($r['keyA'], $r['field1'], $r['field2'], $r['field3']); if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; exit(); } while($stmt->fetch()){ foreach( $r as $key=>$value ) { $row_tmb[ $key ] = $value; } $r[] = $row_tmb; } return $r; Quote Link to comment https://forums.phpfreaks.com/topic/275736-memory-issue-with-mysqli-code/ Share on other sites More sharing options...
jazzman1 Posted March 16, 2013 Share Posted March 16, 2013 Maybe, you have open more than one mysqli statements connection to the server, I don't know Quote Link to comment https://forums.phpfreaks.com/topic/275736-memory-issue-with-mysqli-code/#findComment-1419002 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.