Ge64 Posted May 17, 2008 Share Posted May 17, 2008 I'm making a very simple app at the moment but I'm running into something I can't explain. I have a sql query which is succesful and the result is in $mysqlresult. Whenever I do the following, everything turns out fine (there are 2 rows): $row = mysql_fetch_assoc($mysqlresult); echo $row['data']; mysql_data_seek($mysqlresult, 1); $row = mysql_fetch_assoc($mysqlresult); echo $row['data']; But when I use the normal way: while($row = mysql_fetch_assoc($mysqlresult)) { echo $row['data']; } it doesn't output anything, not even anything I echo before or after that, as if PHP locks up on the loop. I'm using the almost latest version of PHP. Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/ Share on other sites More sharing options...
phpzone Posted May 17, 2008 Share Posted May 17, 2008 If you output something after the loop does the output appear? Just to test you're not hitting an error that's not being displayed. When developing, if you have access to the server, I always find it useful to have an SSH terminal open and tail the apache error log as sometimes your errors end up in the log if they are parsing errors but not on screen. Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/#findComment-543454 Share on other sites More sharing options...
Ge64 Posted May 17, 2008 Author Share Posted May 17, 2008 No, i have echo's and even just HTML after and before the php code and it doesn't output anything. I actually have physical and SSH access to the server and I even had an ssh window open to test the mysql queries. I'll try to find the error log, but is there any way I can get the error to display through the browser instead? Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/#findComment-543456 Share on other sites More sharing options...
Ge64 Posted May 17, 2008 Author Share Posted May 17, 2008 I found the log and found the problem The problem was whitespace. When I removed the 4 spaces before the 'echo' command inside the loop, it worked. True, I copy/pasted the code from Safari (shame on me) but it appeared as normal spaces in BBEdit. I put back new spaces and it still works so I suppose they weren't actually 'spaces'. This was the error: [error] PHP Fatal error: Call to undefined function \xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0echo() in /Users/ge64/Sites/knowledgebase/action.php on line 27 Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/#findComment-543465 Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 a BBEdit tool that I use A LOT when copying/pasting from the web is Text > Zap Gremlins... That command finds all invisible code-crashing stuff and can either delete it or replace it with something else. I often replace with a bullet (on OS X, Alt- to find oddities in HTML, or simply replace with a space for PHP copied from here and elsewhere. FYI. Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/#findComment-543487 Share on other sites More sharing options...
Ge64 Posted May 17, 2008 Author Share Posted May 17, 2008 Thanks, I had read about that in the manual and then completely forgot again immediately Link to comment https://forums.phpfreaks.com/topic/106037-output-nothing-when-use-loop-output-fine-when-done-manually/#findComment-543526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.