By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Parse Errror help please.

P: 2
Hi, I was updating my website, well trying to... and I somehow messed it up. I didnt build it, I bought it so I don't know alot about programming. I receive these errors when going to minbiketrader.com :

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/content/m/i/n/minibiketrader/html/index.php on line 2

Parse error: parse error, unexpected T_REQUIRE_ONCE in /home/content/m/i/n/minibiketrader/html/index.php on line 3

Here is the coding,
Expand|Select|Wrap|Line Numbers
  1. <?
  2. require_once 'common.php';
  3. require_once 'config.php'; // Configuration information
  4. require_once 'include/mysql.php';
  5. // Access to all the database functions
  6.  
  7. // Open the database
  8. $db = new MySQL;
  9. if(!$db->init()) {
  10. echo '<div>Cannot open database</div>';
  11. exit;
  12. }
  13.  
  14. $cat = (int)$_REQUEST['cat'];
  15. $db->AUTOAPPROVE = false;
  16. $ADMIN_MODE = false;
  17. $msg = '';
  18. $title = 'Links ';
  19. $linkcats = array();
  20. $links = array();
  21. $newlinks = array();
  22. $i = 0;
  23.  
  24. if ($_REQUEST['KeyWords'])
  25. {
  26. $links = $db->search($_REQUEST['KeyWords']);
  27. //print '<pre>'; print_r($links);
  28. if(!is_array($links))
  29. {
  30. $title = "Search Results";
  31. $msg = "No Matches";
  32. // start_page($junk,$title,$msg);
  33. }
  34. else
  35. {
  36. $total = count($links);
  37. $title = "Search Results";
  38. $msg = "Search returned $total matches";
  39. $lnks = array();
  40. foreach($links as $lnk)
  41. {
  42. if (!in_array($lnk['CatID'], $lnks))
  43. {
  44. $lnks[] = $lnk['CatID'];
  45. $linkcats[$i]['CatId'] = $lnk['CatID'];
  46. $linkcats[$i]['CatName'] = $lnk['CatName'];
  47. $i++;
  48. }
  49. }
  50. //print '<pre>'; print_r($linkcats);
  51. }
  52. }
  53. else
  54. {
  55. $linkcats = $db->get_Cats($cat);
  56. //links
  57. $hotlinks = array();
  58. if ((int)$cat == 0)
  59. {
  60. $hotlinks = $db->get_HotLinks();
  61. $newlinks = $db->get_NewLinks();
  62. }
  63. $links = array_merge($hotlinks, $db->get_Links($cat));
  64. }
  65.  
  66.  
  67. $t->setRoot('../templates');
  68. $t->loadTemplatefile('link.htm');
  69. $t->setCurrentblock('__global__');
  70. $t->setVariable('pagedesc', 'New and used pocketbikes, pocketbide racing, event calendar, forum and links');
  71. $t->setVariable('pagedkeywords', 'pocket bike minimoto minibike used pocketbikes for sale');
  72. $t->setVariable('msg', $msg);
  73. $t->setVariable('trail', breadcrumbs($cat));
  74. $t->setVariable('CatID', $cat);
  75.  
  76. // categories
  77. for ($i=0; $i < round(count($linkcats)/2); $i++)
  78. {
  79. $t->setCurrentBlock('link_categories_left');
  80. $t->setVariable('CatID', $linkcats[$i]['CatID']);
  81. $t->setVariable('CatName', stripslashes($linkcats[$i]['CatName']));
  82. $t->parseCurrentBlock('link_categories_left');
  83. }
  84. for ($i; $i < round(count($linkcats)); $i++)
  85. {
  86. $t->setCurrentBlock('link_categories_right');
  87. $t->setVariable('CatID', $linkcats[$i]['CatID']);
  88. $t->setVariable('CatName', stripslashes($linkcats[$i]['CatName']));
  89. $t->parseCurrentBlock('link_categories_right');
  90. }
  91.  
  92. //print '<pre>';print_r($links);print '</pre>';
  93. for ($i=0; $i < count($links); $i++)
  94. {
  95. if ((int)$links[$i]['SortWeight'] < 6)
  96. {
  97.  
  98. $t->setVariable('LinkStyle', 'featlink');
  99. }
  100. else
  101. {
  102. $t->setVariable('LinkStyle', 'normlnk');
  103. }
  104. $t->setCurrentBlock('links');
  105. $t->setVariable('Url', stripslashes($links[$i]['Url']));
  106. $t->setVariable('LinkName', stripslashes($links[$i]['LinkName']));
  107. $t->setVariable('Description', stripslashes($links[$i]['Description']));
  108. $t->parseCurrentBlock('links');
  109. }
  110. if (!count($newlinks))
  111. {
  112. $t->hideBlock('newlinks');
  113. }
  114. else
  115. {
  116. for ($i=0; $i < count($newlinks); $i++)
  117. {
  118. $t->setCurrentBlock('newlinks');
  119. $t->setVariable('Url', $newlinks[$i]['Url']);
  120. $t->setVariable('LinkName', stripslashes($newlinks[$i]['LinkName']));
  121. $t->setVariable('Description', stripslashes($newlinks[$i]['Description']));
  122. $t->parseCurrentBlock('newlinks');
  123. }
  124. }
  125.  
  126. parseHeader($t, $title);
  127. parseFooter($t);
  128. $t->show();
  129. ?>
  130.  
If someone could please help me it would be GREATLY appreciated.
Thanks!
May 21 '07 #1
Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Try changing the <? on line 1 to <?php

On older versions of PHP the <? tags are enabled by default, on newer version, however, they are not.

I strongly reccomend always using the <?php tags
May 21 '07 #2

P: 2
didnt work.

Expand|Select|Wrap|Line Numbers
  1. Warning: main(../include/hoo.php): failed to open stream: No such file or directory in /home/content/m/i/n/minibiketrader/html/config.php on line 3
  2.  
  3. Fatal error: main(): Failed opening required '../include/hoo.php' (include_path='.:/usr/local/lib/php') in /home/content/m/i/n/minibiketrader/html/config.php on line 3
  4.  
my config file,
Expand|Select|Wrap|Line Numbers
  1. <?
  2. // To improve security, chmod 600 this include file - and keep it outside the web-tree:
  3. require_once '../include/hoo.php';
  4.  
  5. $TEMPLATE_FILE = "index_t.htm";          // Path to the template file
  6. $SITE_NAME = "Minibike Links";            // Title of the site (keep short)
  7. $ADMIN_MODE = false;                     // Set true for admin version
  8. $SEE_ALL_SUBMISSIONS = true;             // Set false to show submissions in this category only
  9. $SITE_URL = "http://www.minibiketrader.com";  // Set real URL of site
  10. $SITE_DIR = "index.php";      // Appended to SITE_URL for complete address
  11. $FULL_ADMIN_ACCESS = true;            // True to allow admin to create categories
  12. $TOP_CAT_NAME = "Top";                // Name of the top "category"
  13. $ADMIN_EMAIL = "info@minibiketrader.com"; // Admin email address used for new links
  14. $SMTP_HOSTNAME = "localhost";
  15. $SMTP_LOCALHOST = "127.0.0.1";
  16. $AUTOAPPROVE = false;                 // True to automatically approve submissions
  17. $REQUIRE_SUBMIT_EMAIL = false;        // True to require email for any submissions
  18. $SQL_CAT_TBL = "hoo_Categories";        // MySQL table name for the categories table
  19. $SQL_LNK_TBL = "hoo_Links";             // MySQL table name for the links table
  20.  
  21.  
  22. // Expand CatID to whole trail
  23. function breadcrumbs($CatID=0)
  24. {
  25.     global $db;
  26.     global $ADMIN_MODE;
  27.     global $SITE_DIR;
  28.  
  29.     $db->get_ParentsInt($CatID);
  30.     $path = $db->TRAIL;
  31.     if(!empty($path) and $CatID !=0)
  32.     {
  33.         while ( list ( $key,$val ) = each ($path))
  34.         {
  35.             $CatID        = stripslashes($val["CatID"]);
  36.             $CatName    = stripslashes($val["CatName"]);
  37.             if ($CatID == $val["CatID"])
  38.             {
  39.                 $trail .= $CatName .':&nbsp;';
  40.             }
  41.             else
  42.             {
  43.                 $trail = "<a href=\"$SITE_DIR?viewCat=$CatID\" class=hoo>$CatName</a>:&nbsp;" . $trail;
  44.             }
  45.         }
  46.     }
  47.     else
  48.     {
  49.         $trail = "";
  50.     }
  51.     return "<A HREF=\"$SITE_DIR\" class=\"hoo\">Top</A>: &nbsp;" . $trail;
  52. }
  53.  
  54. function breadcrumbs_txt($CatID="")
  55. {
  56.     global $db;
  57.     if(empty($CatID)) { return; }
  58.     $db->get_ParentsInt($CatID);
  59.     $path = $db->TRAIL;
  60.     if(!empty($path))
  61.     {
  62.         while ( list ( $key,$val ) = each ($path))
  63.         {
  64.             $CatID        = stripslashes($val["CatID"]);
  65.             $CatName    = stripslashes($val["CatName"]);
  66.             if ($trail) {
  67.                 $trail    = "$CatName: $trail";
  68.             } else {
  69.                 $trail    = $CatName;
  70.             }
  71.         }
  72.     } else {
  73.         $trail = "-";
  74.     }
  75.     return $trail;
  76. }
  77.  
  78. // drop-down box for available categories
  79. function get_cat_selection($SelName = "CatID", $IncludeTop = true, $SecSel = 0, $IncludeNone = false)
  80. {
  81.     global $db;
  82.     global $ADMIN_MODE;
  83.     global $TOP_CAT_NAME;
  84.     $select =  "<select name=\"$SelName\">\n";
  85.     if ($IncludeNone)
  86.     {
  87.         if ($SecSel == -1)
  88.         {
  89.             $sel = "selected";
  90.         }
  91.         else
  92.         {
  93.             $sel = "";
  94.         }
  95.         $select .=  "<option $sel value=\"NONE\">- none -</option>";
  96.         if ($SecSel == 0)
  97.         {
  98.             $sel = "selected";
  99.         }
  100.         else
  101.         {
  102.             $sel = "";
  103.         }
  104.         $select .=  "<option $sel value=\"0\">$TOP_CAT_NAME</option>";
  105.     }
  106.     elseif ($IncludeTop)
  107.     {
  108.         if (($SecSel == 0) or ($SecSel == -1))
  109.         {
  110.             $sel = "selected";
  111.         }
  112.         else
  113.         {
  114.             $sel = "";
  115.         }
  116.         $select .=  "<option $sel value=\"0\">$TOP_CAT_NAME</option>";
  117.     }
  118.     $secs = $db->get_AllCats();
  119.     if(!empty($secs))
  120.     {
  121.         while (list ($key, $val) = each ($secs))
  122.         {
  123.             // Run for all sections:
  124.             $CatID   = $val["CatID"];
  125.             $CatName = breadcrumbs_txt($CatID);
  126.             if ($CatID == $SecSel)
  127.             {
  128.                 $sel = "selected";
  129.             }
  130.             else
  131.             {
  132.                 $sel = "";
  133.             }
  134.             $select .=  "<option $sel value=\"$CatID\">$CatName</option>\n";
  135.         }
  136.     }
  137.     $select .=  "</select>\n";
  138.     return $select;
  139. }
  140.  
  141. // Mail the admin anytime a new link is submitted
  142. function mail_new_link($postData = "")
  143. {
  144.     global $db;
  145.     global $ADMIN_EMAIL;
  146.  
  147.     if( (empty($postData)) or (!is_array($postData)) ) { return false; }
  148.     if ($ADMIN_EMAIL == "") { return false; }
  149.  
  150.     $CatID = $postData["CatID"];
  151.     $Url = addslashes(htmlentities($postData["Url"]));
  152.     $Description = addslashes(htmlentities($postData["Description"]));
  153.     $LinkName = addslashes(htmlentities($postData["LinkName"]));
  154.     $SubmitName = addslashes(htmlentities($postData["SubmitName"]));
  155.     $SubmitEmail = addslashes(htmlentities($postData["SubmitEmail"]));
  156.     $SubmitDate = time();
  157.  
  158.     // Get category information
  159.     $CatName = breadcrumbs_txt($CatID);
  160.     if (empty($CatName)) {
  161.         $CatName = "Unknown";
  162.     }
  163.  
  164.     $Subject = "New Link: ";
  165.     $Subject .= substr($LinkName, 0, 60);
  166.     if ($LinkName != substr($LinkName, 0, 60)) {
  167.         $LinkName .= "...";
  168.     }
  169.     $Subject = trim($Subject);
  170.  
  171.     $Body = "User \"$SubmitName\" <".$SubmitEmail."> submitted this link in category $CatName:\n\n";
  172.     $Body .= "$LinkName at <$Url>\n\n";
  173.     $Body .= "$Description\n\n";
  174.     if ($AUTOAPPROVEQUE) {
  175.         $Body .= "This link was auto-approved.\n";
  176.     } else {
  177.         $Body .= "This link needs approval.\n";
  178.         $Body .= "http://$_SERVER[SERVER_NAME]/links/admin.php\n";
  179.     }
  180.  
  181.     $From = "$SubmitName<".$SubmitEmail.">";
  182.  
  183.     // Send the email notice if email defined
  184.     if ($ADMIN_EMAIL) {
  185.         // function smtp_mail($from, $to, $subject, $body, $replyto = "", $bcc = "")
  186.         smtp_mail($ADMIN_EMAIL, $ADMIN_EMAIL, $Subject, $Body, $From);
  187.     }
  188.  
  189.     return;
  190. }
  191. // Send mail function
  192. function smtp_mail($from, $to, $subject, $body, $replyto = "", $bcc = "") {
  193.    require('../include/class.phpmailer.php');
  194.     // Prepare SMTP class
  195.     $smtp = new PHPMailer();
  196. //    $smtp->host_name = "localhost";
  197. //    $smtp->localhost = "127.0.0.1";
  198.  
  199.     $smtp->From = $from;
  200.     $smtp->AddAddress($to);
  201.     if (!empty($replyto))
  202.     {
  203.         $smtp->AddReplyTo($replyto);
  204.     }
  205.     if (!empty($bcc))
  206.     {
  207.         $smtp-AddBCC($bcc);
  208.     }
  209.     $smtp->Subject = $subject;
  210.     $smtp->Body = $body;
  211.     $smtp->IsMail();
  212.     if (!$smtp->Send())
  213.     {
  214.         echo "<p>Could not send the message to $to.\nError: " . $smtp->ErrorInfo . "</p>\n";
  215.     }
  216. }
  217.  
  218.  
  219. // Print page header based on template file
  220. function print_header($CatID="",$title="")
  221. {
  222.     global $TEMPLATE_FILE;
  223.     global $ADMIN_MODE;
  224.     global $menu;
  225.  
  226.     $trail = breadcrumbs($CatID);
  227.     if ($ADMIN_MODE)
  228.     {
  229.             $trail .= "  :<a href=\"admin.php?exit_admin=1\" class=hoo>Exit Admin</a>";
  230.     }
  231.  
  232.     $filename = $TEMPLATE_FILE;
  233.     $fd = fopen ($filename, "r");
  234.     $c = fread ($fd, filesize ($filename));
  235.     fclose ($fd);
  236.  
  237.     $c = ereg_replace('@MENU@', $menu, $c);
  238.     $c = ereg_replace("@TRAIL@", $trail, $c);
  239.     $c = eregi_replace("@PHPHOO_BODY@.*", "", $c);
  240.     print ($c);
  241. }
  242. ?>
  243.  
May 21 '07 #3

Atli
Expert 5K+
P: 5,058
Actually, yes it did.

If those are the error messages, you might have noticed that they have changed. Instead of complaining about weird characters, they are now telling you that you are trying to include a file that it can not find.
Ergo, the change that you made fixed something, but something is still broken.
So, now that we have established that <? does not work, replacing them with <?php in the rest of your code would be an excelent start, if you haven't already done so.

Now to fix your new error, you have to make sure the files you are trying to include exist and that the include statements have the correct paths.
I would try changing the "../" to "./" or even just "/". Those bloody things never seem to do what you want them to.

And would you please post your code inside code tags. (Instructions in the box on the right when you post!)
May 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.