cudsuk Posted January 6, 2013 Share Posted January 6, 2013 Hi everyone , I am new to php and can not find this answer on google hence the signup First let me explain what's going on , i was given a ancient video hosting script that is around 7 years old and no longer supported ,, all web site traces have gone I have fixed a lot of code like ereg to preg_match , mysql_escape_string was deprecated so using mysql_real_escape_string ect My problem is (see attachment) I have code after my login , it is this i believe found in my template.php , but i can not find a solution to fix it , hence the post , so i can look and learn what to do <? } else { echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>'; echo '<p> <a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'" class="lilogin"> visit your profile</a><br>'; echo ' <a href="'.$siteurl.'/logout.php" class="lilogin"> log out</a></p>'; } ?> Cheers if you can help Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 6, 2013 Share Posted January 6, 2013 Use <?php instead of <? Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 6, 2013 Author Share Posted January 6, 2013 Gives me a Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\videos\template.php on line 41 [/b] </form> <?php } else { echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>'; echo '<p> <a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'" class="lilogin"> visit your profile</a><br>'; echo ' <a href="'.$siteurl.'/logout.php" class="lilogin"> log out</a></p>'; } ?> </div><img src="<?=$siteurl?>/images/log-bottom.gif" alt="border bottom" /><div class="leftcol-top">Top Rated Media</div> <div class="leftcol-div"> [b] Thanks for the help > posted a little more code as might throw some light on it Quote Link to comment Share on other sites More sharing options...
haku Posted January 7, 2013 Share Posted January 7, 2013 (edited) In this code: <?php } You have a closing parenthesis. It appears that there most likely wasn't an opening parenthesis. Edit: damn this editor is hokey. Edited January 7, 2013 by haku Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 7, 2013 Author Share Posted January 7, 2013 (edited) Thanks , i did a little research intoit and it says as most likely was missing a semi colon , so i checked but can't see anything missing in them lines , here is the entire page , maybe you can spot something i can't as also am being told via google , as html is maybe not being correctly listed after , if that makes sense ? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My site.</title> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="author" content="mysite.com" /> <meta name="keywords" content="Video, Media, Script, Free, Search" /> <meta name="description" content="<?=$site_description?>" /> <meta name="robots" content="all" /> <link rel="stylesheet" type="text/css" href="<?=$siteurl?>/style/layout.css" /> </head> <body> <div id="outer"> <div id="hdr"> <img style="float:left;" src="<?=$siteurl?>/images/h-left.gif" alt="header left" /> <img id="logo" style="float:left;" src="<?=$siteurl?>/images/logo.gif" alt="Media Site" /> <p id="h-title"><a href="#">My site</a></p> <img style="float:right;" src="<?=$siteurl?>/images/h-right.gif" alt="header right" /> <div id="nav"> <form id="searchform" action='<?=$siteurl?>/search.php' method='post' name="search"> <input type="text" name="query" value="Search Media" class="search_input" size="20"> <input type="button" name="search" value="Search" class="search_btn"> </form> <a href="<?=$siteurl?>/index.php"><img src="<?=$siteurl?>/images/nav-bullet.gif" alt="Home" /> Home</a><a href="<?=$siteurl?>/register.php"><img src="<?=$siteurl?>/images/nav-bullet.gif" alt="Register" /> Register</a><a href="<?=$siteurl?>/upload.php"><img src="<?=$siteurl?>/images/nav-bullet.gif" alt="Upload" /> Upload</a><a href="<?=$siteurl?>/news.php?show=1"><img src="<?=$siteurl?>/images/nav-bullet.gif" alt="News" /> News</a><a href="<?=$siteurl?>/contact.php"><img src="<?=$siteurl?>/images/nav-bullet.gif" alt="Contact" />Contact Us</a> </div> </div> <table id="main" cellspacing="0" cellpadding="0" bordercolor="000000" border="0" style="border-style:collapse;"> <tr> <td class="leftcol" valign="top;"> <img src="<?=$siteurl?>/images/log-top.gif" alt="border top" /><div class="log"> <? if (! isset($_SESSION['LOgIn'])) { ?> <form action='<?=$siteurl?>/login.php' method='post' name="login" ><br> <input type="text" name="username" value="username" class="log_input" size="20"><p> <input type="password" name="password" value="password" class="log_input" size="20"> <p align="right"> <input type="image" src="<?=$siteurl?>/images/login.gif" name="login" value="login" class="log_btn" /></p> </form> <? } else { echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>'; echo '<p> <a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'" class="lilogin"> visit your profile</a><br>'; echo ' <a href="'.$siteurl.'/logout.php" class="lilogin"> log out</a></p>'; } ?> </div><img src="<?=$siteurl?>/images/log-bottom.gif" alt="border bottom" /><div class="leftcol-top">Top Rated Media</div> <div class="leftcol-div"> <p><? include "stat_toprated.php"; ?></p> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Categories</div> <div class="leftcol-div"> <?=get_categories_list($siteurl)?> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Links</div> <div class="leftcol-div"> <? include "links.php"; ?> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Media Stats</div> <div class="leftcol-div"> <p><? include "stat_total_games.php"; ?></p> <p><? include "stat_whos_online.php"; ?></p> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /> </td> <td class="rightcol"> <?php include('ads_top.php'); ?> <?=$news_content?> <?=$content?> <?php include('ads_second_top.php'); ?> </td> </tr> </table> <div id="bottom"><img style="float:left;" src="<?=$siteurl?>/images/f-left.gif" alt="bottom left" /><div id="footer" align="center"><a href="http://www.mysite.com">© 2013 mysite.com</a></div><img style="float:right;" src="<?=$siteurl?>/images/f-right.gif" alt="bottom right" /></div> </div> </body> </html> Ok i notice this line shouldn't be here as this is what is given if use frontpage etc (which is what's listed also) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Haku , your exactly right i do ? before this <php? } is </form> and html code before hand but no bracket ? Could you explain how to correct it please so i can make a note and hopefully correct it myself if come across it again I understand that if it has a closed bracket , it means it should have a { before somewhere but not sure where as just starting out Cheers (we all had to start somewhere ) Edited January 7, 2013 by cudsuk Quote Link to comment Share on other sites More sharing options...
haku Posted January 7, 2013 Share Posted January 7, 2013 The problem is that the code there is crappy. But the real problem is that it is using short tags: <? You need to change them all to full tags <?php Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 7, 2013 Author Share Posted January 7, 2013 (edited) Yes , your right it is ancient from around 2006/2007 but it is a simple script for what i need , and it's a good learning experience , i have managed to sort some out but this is the only one i couldn't find a answer too thanks so much for your help sorry forgot to ask - i see near bottom on <?php include , so do i just do include ones , or everyone that starts as <? , sorry if sounds stupid ? Edited January 7, 2013 by cudsuk Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 7, 2013 Author Share Posted January 7, 2013 (edited) Ok , thanks for the <?php tip I didn't place it everywhere i did a trial and error and i was half right with asking the question above Doing this lost the code , but i also lost my info in blocks for links , top rated , media stats <?php if (! isset($_SESSION['LOgIn'])) { ?> <form action='<?=$siteurl?>/login.php' method='post' name="login" ><br> <input type="text" name="username" value="username" class="log_input" size="20"><p> <input type="password" name="password" value="password" class="log_input" size="20"> <p align="right"> <input type="image" src="<?=$siteurl?>/images/login.gif" name="login" value="login" class="log_btn" /></p> </form> <?php } To fix it i was right needed to go in front of include else { echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>'; echo '<p> <a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'" class="lilogin"> visit your profile</a><br>'; echo ' <a href="'.$siteurl.'/logout.php" class="lilogin"> log out</a></p>'; } ?> </div><img src="<?=$siteurl?>/images/log-bottom.gif" alt="border bottom" /><div class="leftcol-top">Top Rated Media</div> <div class="leftcol-div"> <p><?php include "stat_toprated.php"; ?></p> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Categories</div> <div class="leftcol-div"> <?=get_categories_list($siteurl)?> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Links</div> <div class="leftcol-div"> <?php include "links.php"; ?> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /><div class="leftcol-top">Media Stats</div> <div class="leftcol-div"> <p><?php include "stat_total_games.php"; ?></p> <p><?php include "stat_whos_online.php"; ?></p> </div><img src="<?=$siteurl?>/images/leftcol-bottom.gif" alt="border bottom" /> </td> <td class="rightcol"> <?php include('ads_top.php'); ?> <?=$news_content?> <?=$content?> <?php include('ads_second_top.php'); ?> </td> </tr> </table> <div id="bottom"><img style="float:left;" src="<?=$siteurl?>/images/f-left.gif" alt="bottom left" /><div id="footer" align="center"><a href="http://toonfreaks.co.nr">© 2013 toonfreaks.co.nr</a></div><img style="float:right;" src="<?=$siteurl?>/images/f-right.gif" alt="bottom right" /></div> </div> </body> </html> So thanks guys , i guess this is my first lesson , get a tip and d.i.y , cheers for the support and help Edited January 7, 2013 by cudsuk Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 7, 2013 Share Posted January 7, 2013 You need to change these too: <?= With: <?php echo The former is the the short code version, which won't work as short tags are disabled. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 7, 2013 Share Posted January 7, 2013 (edited) The former is the the short code version, which won't work as short tags are disabled. <?= works even when short tags are disabled. (Edit: >=5.4 http://us3.php.net/manual/en/function.echo.php) Edited January 7, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 7, 2013 Author Share Posted January 7, 2013 To Christian F. It works as <?= But if you feel <?php echo Is better coding then i am happy to try with that Jessica , thanks for your post also as you are indeed correct also , if i used just <?php = it gave more errors I shall however try Christians any way as like it to be as up to date as i can get it Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 7, 2013 Share Posted January 7, 2013 There's no such thing as <?php= You can use <?= if you are 5.4 or greater. They plan to always support <?= from now on. You can use <?php echo at any time. Quote Link to comment Share on other sites More sharing options...
cudsuk Posted January 7, 2013 Author Share Posted January 7, 2013 Ok thanks for clearing that up for me 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.