so i'm learning php + mysql right now. the example code was building a table with queried info and i decided that i wanted to try a different method to implement the same thing. apparently i didn't understand it as well as i thought because i caused an infinite loop within a row and killed my machine as firefox tried to show me everything...
thought this could be a thread where we share humorous coding errors?
this post has been archived.
it sucks that as i was typing that i figured out how foreach works and how it's different from while... seems like i should've already known this.
while ($row = mysql_fetch_assoc($results)) {
echo "<tr>\n";
/* so this doesn't work, but i had to try...
while ($row) {
echo "<td>\n";
echo $row['movie_name'];
echo "</td>\n";
echo "<td>\n";
echo $row['movietype_label'];
echo "</td>\n";
}
*/
foreach($row as $value) {
echo "<td>\n";
echo $value;
echo "</td>\n";
}
echo "</tr>\n";
}
I've made the infinite loop error before when I've forgotten to increment a variable at the end of a loop. then I started using for loops instead! I've never thought of using foreach loops to loop over mysql_fetch_assoc results.
with the infinite loops I've just been able to stop the page from loading and it's been okay.
oh, and I've made some silly mistakes before like editing the wrong file or something and wondering why the hell the content in my browser isn't changing!
towards the end of my job, i would do that (edit a file in /branches/live/ instead of /trunk/ in svn) and get so unbelievably angry
i almost punched my lcd as hard as possible once
i'm so glad that job is over