TheMovieman Posted October 11, 2009 Share Posted October 11, 2009 Ok, so even though in the past this code has worked for my header, for some reason it's not working now. Here is the code I have: ><?php if ($type == movie) { echo "<TITLE>Movieman's Guide to the Movies >> Review Index >> Movies</TITLE>"; } if ($type == dvd) { echo "<TITLE>Movieman's Guide to the Movies >> Review Index >> DVDs</TITLE>"; } if ($type == hidef) { echo "<TITLE>Movieman's Guide to the Movies >> Review Index >> Hi-Def Titles</TITLE>"; } ?> I have one for the 3 different review indexes on my site: http://www.moviemansguide.com/reviewindex.php?type=dvd http://www.moviemansguide.com/reviewindex.php?type=hidef http://www.moviemansguide.com/reviewindex.php?type=movie And even though each one will grab the correct info, the header is not working anymore. Any ideas of why? Quote Link to comment Share on other sites More sharing options...
OJB Posted October 11, 2009 Share Posted October 11, 2009 You don't appear to have any quotation marks around the 'dvd', 'hidef' and 'movie'. Why not do something like this instead: > switch ($type) { case 'dvd': $title = 'DVDs'; break; case 'hidef': $title = 'Hi-Def Titles'; break; case 'movie': default: $title = 'Movies'; break; } echo '<TITLE>Movieman's Guide to the Movies >> Review Index >> '. $title.'</TITLE>'; Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted October 11, 2009 Author Share Posted October 11, 2009 (edited) I'll give that a try, thanks . Still, not sure why it stopped working after so many years. Change in PHP? Edited October 11, 2009 by TheMovieman Quote Link to comment Share on other sites More sharing options...
OJB Posted October 11, 2009 Share Posted October 11, 2009 (edited) How recently has it broken? How are you assigning the $type variable? Are you doing something like $type = $_GET['type']; or are you relying on register_globals to assign the variable automatically? If the latter, then it could be to do with register_globals being disabled on your account. If this is the case then I advise you to run through your existing code and ensure you are not relying on automatic variable creation via register_globals anywhere and you are manually assigning them yourself. I could be way off with the register_globals guess, not even sure TCH have it enabled on any of the linux boxes anyway, but it is one explanation. Edit: you will have to escape the apostrophe in "Movieman's" in the title in the code I wrote. Like this: > echo '<TITLE>Movieman\'s Guide to the Movies >> Review Index >> '.$title.'</TITLE>'; Sorry about that Edited October 11, 2009 by OJB Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted October 11, 2009 Author Share Posted October 11, 2009 (edited) Ah, I recently had TCH disable register_globals due to a potential security issue with an Coppermine (I think that's it) image gallery (it gave me a warning). I checked my other pages and those are fine. But I am assigning the type variable, yes. Anyway, when I get a chance, I will try out the code. Thanks for your help. Edited October 11, 2009 by TheMovieman Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted October 12, 2009 Author Share Posted October 12, 2009 Hi OJB, Well, unfortunately it didn't work. Page displays fine but still no header. Guess it has something to do with that register_globals, not sure how to get around that (the other pages I have are connected to a database so that's probably why those show right). Quote Link to comment Share on other sites More sharing options...
OJB Posted October 12, 2009 Share Posted October 12, 2009 (edited) You said before you ARE assigning the variable didn't you? Just in case you aren't, try this in your header: > $type = $_GET['type']; switch ($type) { case 'dvd': $title = 'DVDs'; break; case 'hidef': $title = 'Hi-Def Titles'; break; case 'movie': default: $title = 'Movies'; break; } echo '<title>Movieman\'s Guide to the Movies >> Review Index >> '. $title.'</title>'; If this is what you are doing, feel free to PM me some of the code and I will have a look through it for you and see if I can figure out what is going wrong. Edited October 12, 2009 by OJB Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted October 12, 2009 Author Share Posted October 12, 2009 (edited) Ok, that seemed to work. What happened was I was assigning the variable below but not in the header, so that did it. So simple, can't believe I forgot about that, lol. Edited October 12, 2009 by TheMovieman Quote Link to comment Share on other sites More sharing options...
OJB Posted October 12, 2009 Share Posted October 12, 2009 Awesome! Glad it worked. Don't worry, the simplest things are sometimes the easiest to miss. I do it all the time when coding. Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted October 12, 2009 Author Share Posted October 12, 2009 Thanks for the help! Quote Link to comment Share on other sites More sharing options...
carbonize Posted October 29, 2009 Share Posted October 29, 2009 Just as a side note you should change the >> to >> Quote Link to comment 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.