Swarfega Posted December 31, 2012 Share Posted December 31, 2012 (edited) Hey. I've just setup the Comment-Part of my custom-scripted Foto Album system, and it's working properly, apart from one issue which I simply cannot find in the while loop. Either it's something easy and I'm missing it or there's something hidden that I can't find. When I mean "Random 'Array' Echo" I don't mean an actual Array Printing data, what I mean is that the word 'Array' itself is printed. Here's what happens without a comment: http://i.imgur.com/NNbFy.png Here's what happens with a comment: http://i.imgur.com/16mbM.png And here's the code processing the Data: $sql = "SELECT * FROM imagecomments WHERE imageid='".$_GET['imageid']."' AND targetid='".$_GET['targetid']."' ORDER BY UNIX_TIMESTAMP(timehappen) DESC LIMIT ".$min.", ".$limit; $query = mysql_query( $sql ); $rows = mysql_num_rows( $query ); while($row = mysql_fetch_array($query)) { $data .= "<tr>"; if($durp == 0) { $data .= "<td class='cellone'><img src='".$row['profilepic']."' ></td>"; } else { $data .= "<td class='celltwo'><img src='".$row['profilepic']."' ></td>"; } if($row['connected'] == "online") { if($durp == 0) { $data .= "<td class='cellone' style='max-width: 600px; overflow:auto; word-wrap:break-word;'><img src='online.png' width='5' height='5'> <a href='profile.php?uid=".$row['uid']."'>" . ucfirst($row['sender']) . "</a> - <font color='green'>". $row['timehappen'] . "</font> <br/> ".$row['message']."</td>"; $durp = 1; } else { $data .= "<td class='celltwo' style='max-width: 600px; overflow:auto; word-wrap:break-word;'><img src='online.png' width='5' height='5'> <a href='profile.php?uid=".$row['uid']."'>" . ucfirst($row['sender']) . "</a> - <font color='green'>". $row['timehappen'] . "</font> <br/> ".$row['message']."</td>"; $durp = 0; } } else { if($durp == 0) { $data .= "<td class='cellone' style='max-width: 600px; overflow:auto; word-wrap:break-word;'><img src='offline.png' width='5' height='5'> <a href='profile.php?uid=".$row['uid']."'>" . ucfirst($row['sender']) . "</a> - <font color='red'>". $row['timehappen'] . "</font> <br/> ".$row['message']."</td>"; $durp = 1; } else { $data .= "<td class='celltwo' style='max-width: 600px; overflow:auto; word-wrap:break-word;'><img src='offline.png' width='5' height='5'> <a href='profile.php?uid=".$row['uid']."'>" . ucfirst($row['sender']) . "</a> - <font color='red'>". $row['timehappen'] . "</font> <br/> ".$row['message']."</td>"; $durp = 0; } } $data .= "</tr>"; } echo $table1_start . $table_start . $data . $table_end . $table1_end; I know the code itself is very sloppy, but I tend to fix that after everything's already working properly, which currently it is not. I have spent hell of a lot of time trying to find out why it's printing the 'Array' Text/String, but I can't find it. It's evidentally in the $data value but I can't find where. Edit: I'm also using the same Data-Printing system for the User-Individual Guestbooks & the Chat System, and they all work properly, apart from this 'Array' echoing. Edited December 31, 2012 by Swarfega Quote Link to comment https://forums.phpfreaks.com/topic/272549-random-array-echo/ Share on other sites More sharing options...
Jessica Posted December 31, 2012 Share Posted December 31, 2012 Try using print_r on the value to see what's in the array. Or if you're confused about why it's an array you need to look at the code that creates the value. This code doesn't show the creation of $data. Quote Link to comment https://forums.phpfreaks.com/topic/272549-random-array-echo/#findComment-1402385 Share on other sites More sharing options...
Swarfega Posted December 31, 2012 Author Share Posted December 31, 2012 Cheers Jessica, I had forgotten to declare the $data = NULL; , silly mistake. :/ Quote Link to comment https://forums.phpfreaks.com/topic/272549-random-array-echo/#findComment-1402386 Share on other sites More sharing options...
Pikachu2000 Posted December 31, 2012 Share Posted December 31, 2012 Have you checked to see if 'Array' is somehow in the database? That would be my first guess. Either that, or it's happening in code other than what you've posted. Quote Link to comment https://forums.phpfreaks.com/topic/272549-random-array-echo/#findComment-1402388 Share on other sites More sharing options...
Jessica Posted December 31, 2012 Share Posted December 31, 2012 You shouldn't have to declare $data = NULL; unless you're trying to reuse a variable you already had filled with an array. A good reason to use descriptive variable names. All variables contain data. Quote Link to comment https://forums.phpfreaks.com/topic/272549-random-array-echo/#findComment-1402391 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.