i can not find error @ code. problem coming array_push
method (allowed memory size of 134217728 bytes exhausted).
code:
<?php require "dbconnect.php"; $username = $_post['username']; if ($username != '') { $sql = "select * users username='$username'"; $result = mysqli_query($con, $sql); $check = mysqli_fetch_array($result); $data = array(); if (isset($check)) { echo "4"; while ($row = mysqli_fetch_array($result)){ echo "2"; array_push ($data, array('name'=>$row[1], 'username'=>$row[2], 'password'=>$row[3], 'email'=>$row[4])); } echo json_encode(array("response"=>$data)); mysqli_close($con); } else { echo "0"; } } else { echo "3"; } ?>
error:
<br /> <b>fatal error</b>: allowed memory size of 134217728 bytes exhausted (tried allocate 64 bytes) in <b>/home/u766232015/public_html/phpscripts/getuserdata.php</b> on line <b>14</b><br />
that while() loop isn't going ever stop looping, nothing being changed inside it. need move mysqli_fetch_array call loop condition, e.g.
while ($row = mysqli_fetch_array($result)) { ... }
Comments
Post a Comment