wata Posted December 4, 2006 Share Posted December 4, 2006 hi ive done this code but its not printing any ideas why not or have i missed something out here is the code anyway<?php$page=file_get_contents(std_info.txt);$lines=file(std_info.txt)$n=0;print "all the names $page";?> Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/ Share on other sites More sharing options...
trq Posted December 4, 2006 Share Posted December 4, 2006 I'll assume [i]std_info.txt[/i] is a string, not a constant. Your code should be generating errors. Try...[code]<?php $page=file_get_contents("std_info.txt"); print "all the names $page";?>[/code] Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135194 Share on other sites More sharing options...
jsladek Posted December 5, 2006 Share Posted December 5, 2006 Is it printing anything?Should it be... print ("all the names $page");-John Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135198 Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 thank you now it is printing but how can i add a <br> after each name so its in a list? Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135202 Share on other sites More sharing options...
papaface Posted December 5, 2006 Share Posted December 5, 2006 [code]print "<pre>";print_r ("all the names $page");print "</pre>";[/code]I believe that will do what you want. Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135204 Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 what does the <pre> mean? Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135206 Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 Assuming you meant to ask how to add a newline you'll want to use file() not file_get_contents(). eg;[code]<?php $lines = file("std_info.txt"); foreach ($lines as $line) { print "all the names $line</br >"; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135207 Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 [quote author=wata link=topic=117361.msg478805#msg478805 date=1165277295]what does the <pre> mean?[/quote]What does the what mean? What is wrong with your keyboard? Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135208 Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 sorry keyboard fine finger slipt i meant to say what does <pre> mean Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135214 Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 when i put angle bracket it spells "MEAN" so i meant again angle bracket pre close angle bracket Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135215 Share on other sites More sharing options...
papaface Posted December 5, 2006 Share Posted December 5, 2006 [code]<?php $lines = file("std_info.txt"); foreach ($lines as $line) { print "<pre>"; print_r ("all the names $line \n"); print "</pre>"; }?>[/code]^^ altered a bit. Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135220 Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 Its html. You really ought learn it before php. Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135221 Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 thank you all is working :) Link to comment https://forums.phpfreaks.com/topic/29460-why-isnt-it-printing/#findComment-135226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.