WebStyles Posted August 27, 2011 Share Posted August 27, 2011 and don't you thing that learning the very basics is a good idea before starting to code a project ? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262477 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 all i need to is add some php code so i dont have to hyperlink the film directories and be here all day so, the avi directory is films/movie file/movie.avi Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262478 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 yeah man, I know what you need, but the purpose of this forum is to help programmers understand and solve problems. You don't seem to know any programming, and you don't even want to understand it, you basically just want someone to write the code for you (which has already been done, and still you couldn't get it to work)... so we're in a difficult spot right now... I don't mind explaining everything 20 times if necessary until you understand it, but you need to WANT to learn this stuff. Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262479 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 i want to learn on the side aswell. so, this checks the directory? if(is_dir($dir.'/films'.$file)) { $dir holds /films what does $file mean? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262480 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 if(is_dir($dir.'/films'.$file)) { Better, but still wrong. you need: directory/folder/filename.ext each variable ($dir and $file) get replaced by their content, so in your code above, if $file holds the filename (plus extension), what would be the result of what you typed ($dir.'/films'.$file) ? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262481 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 you tell me? idk. Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262482 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 no man, believe me, you NEED to understand this... ok, same example as I gave before... when I do this: $var = "whatever"; echo $var . ' xxx ' . $var . ' xxx'; if I tell you that echo just prints whatever comes after it on the screen, and $var gets replaced with the value that was assigned to it, what would be the result? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262484 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 ok, i understand echo because i am familiar with batch. echo $var . ' DIR' . $var . ' filename.ext'; ? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262485 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 no. forget about your code for now, and just look at this: $var = "whatever"; echo $var . ' xxx ' . $var . ' xxx'; what would be the result printed on the screen? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262486 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 whatever xxx whatever xxx ? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262487 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 YES! ok, what about this? (still ignore YOUR code, just look at the example) $mainDirectory= './films'; $folder = 'Film1'; $filename = 'GoneWithTheWind.avi'; echo $mainDirectory . $folder . $filename; Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262488 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 films/film1/GoneWithTheWind.avi or ./filmsFilm1GoneWithTheWind.avi i dont know if theres mean to be "/" in there or "." ? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262490 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 wrong. please try again. Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262491 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 ./filmsFilm1GoneWithTheWind.avi Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262492 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 YES! so how would you fix this line of code: echo $mainDirectory . $folder . $filename; so that the result is: ./filmsFilm1GoneWithTheWind.avi ?? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262494 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 there is nothing to fix to make it ./filmsFilm1GoneWithTheWind.avi your reply so that the result is: ./filmsFilm1GoneWithTheWind.avi my reply ./filmsFilm1GoneWithTheWind.avi Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262496 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 ok, cool. (it was a trick question) now this: echo $mainDirectory . '/' .$folder . '/' .$filename; ?? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262497 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 im not sure you can have 2 echos? and there is nothing telling the php what $dir is? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262499 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 sorry, was a typo. removed one of them. and $dir doesn't exist in my code. (ignore your original code for goodness sake) Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262500 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 oops i meant $maindirectory Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262502 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 [assume the same values as defined before] Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262504 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 ./films/Film1/GoneWithTheWind.avi Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262509 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 ok, so now that's beginning to look like the path you need right?.. so what would this output? $dir = './films'; $file = 'SomeFile.avi'; echo $dir.'/films'.$file; Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262512 Share on other sites More sharing options...
wkdw1ll1ams Posted August 27, 2011 Author Share Posted August 27, 2011 ./films/filmsSomeFile.avi Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262513 Share on other sites More sharing options...
WebStyles Posted August 27, 2011 Share Posted August 27, 2011 a-ha! So you see how it is wrong in your code? Quote Link to comment https://forums.phpfreaks.com/topic/245688-help-with-this-code-please/page/2/#findComment-1262514 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.