scarhand Posted November 22, 2007 Share Posted November 22, 2007 why isnt this working? when i press the submit button it tries to go to the new page but it seems like it just keeps loading something over and over and over the $myid variable is an integer like 23, or whatever. <?php if (!empty($_FILES['file']['tmp_name'])) { while ($row = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id='$myid'"))) { $oldphoto = $row['myphoto']; echo $oldphoto; } } ?> Quote Link to comment Share on other sites More sharing options...
Orio Posted November 22, 2007 Share Posted November 22, 2007 Because you are lazy. In your while loop the query is being re-run over and over... Should be: <?php if (!empty($_FILES['file']['tmp_name'])) { $result = mysql_query("SELECT * FROM users WHERE id='$myid'"); while ($row = mysql_fetch_array($result)) { $oldphoto = $row['myphoto']; echo $oldphoto; } } ?> Orio. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 22, 2007 Share Posted November 22, 2007 add error reporting to the query <?php <?php if (!empty($_FILES['file']['tmp_name'])) { $q = "Select * from `users` where id = '".$myid."'"; $result = mysql_query($q) or die(mysql_error()."<br />".$q); if(mysql_num_rows($result) >0){ while ($row = mysql_fetch_array($result)) { $oldphoto = $row['myphoto']; echo $oldphoto; } } else{ echo "No Records found."; } } ?> Quote Link to comment 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.