Parse Errror help please.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deerhide
    New Member
    • May 2007
    • 2

    Parse Errror help please.

    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.c om :

    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,
    [Code=php]
    <?
    require_once 'common.php';
    require_once 'config.php'; // Configuration information
    require_once 'include/mysql.php';
    // Access to all the database functions

    // Open the database
    $db = new MySQL;
    if(!$db->init()) {
    echo '<div>Cannot open database</div>';
    exit;
    }

    $cat = (int)$_REQUEST['cat'];
    $db->AUTOAPPROVE = false;
    $ADMIN_MODE = false;
    $msg = '';
    $title = 'Links ';
    $linkcats = array();
    $links = array();
    $newlinks = array();
    $i = 0;

    if ($_REQUEST['KeyWords'])
    {
    $links = $db->search($_REQUE ST['KeyWords']);
    //print '<pre>'; print_r($links) ;
    if(!is_array($l inks))
    {
    $title = "Search Results";
    $msg = "No Matches";
    // start_page($jun k,$title,$msg);
    }
    else
    {
    $total = count($links);
    $title = "Search Results";
    $msg = "Search returned $total matches";
    $lnks = array();
    foreach($links as $lnk)
    {
    if (!in_array($lnk['CatID'], $lnks))
    {
    $lnks[] = $lnk['CatID'];
    $linkcats[$i]['CatId'] = $lnk['CatID'];
    $linkcats[$i]['CatName'] = $lnk['CatName'];
    $i++;
    }
    }
    //print '<pre>'; print_r($linkca ts);
    }
    }
    else
    {
    $linkcats = $db->get_Cats($cat) ;
    //links
    $hotlinks = array();
    if ((int)$cat == 0)
    {
    $hotlinks = $db->get_HotLinks() ;
    $newlinks = $db->get_NewLinks() ;
    }
    $links = array_merge($ho tlinks, $db->get_Links($cat ));
    }


    $t->setRoot('../templates');
    $t->loadTemplatefi le('link.htm');
    $t->setCurrentbloc k('__global__') ;
    $t->setVariable('p agedesc', 'New and used pocketbikes, pocketbide racing, event calendar, forum and links');
    $t->setVariable('p agedkeywords', 'pocket bike minimoto minibike used pocketbikes for sale');
    $t->setVariable('m sg', $msg);
    $t->setVariable('t rail', breadcrumbs($ca t));
    $t->setVariable('C atID', $cat);

    // categories
    for ($i=0; $i < round(count($li nkcats)/2); $i++)
    {
    $t->setCurrentBloc k('link_categor ies_left');
    $t->setVariable('C atID', $linkcats[$i]['CatID']);
    $t->setVariable('C atName', stripslashes($l inkcats[$i]['CatName']));
    $t->parseCurrentBl ock('link_categ ories_left');
    }
    for ($i; $i < round(count($li nkcats)); $i++)
    {
    $t->setCurrentBloc k('link_categor ies_right');
    $t->setVariable('C atID', $linkcats[$i]['CatID']);
    $t->setVariable('C atName', stripslashes($l inkcats[$i]['CatName']));
    $t->parseCurrentBl ock('link_categ ories_right');
    }

    //print '<pre>';print_r ($links);print '</pre>';
    for ($i=0; $i < count($links); $i++)
    {
    if ((int)$links[$i]['SortWeight'] < 6)
    {

    $t->setVariable('L inkStyle', 'featlink');
    }
    else
    {
    $t->setVariable('L inkStyle', 'normlnk');
    }
    $t->setCurrentBloc k('links');
    $t->setVariable('U rl', stripslashes($l inks[$i]['Url']));
    $t->setVariable('L inkName', stripslashes($l inks[$i]['LinkName']));
    $t->setVariable('D escription', stripslashes($l inks[$i]['Description']));
    $t->parseCurrentBl ock('links');
    }
    if (!count($newlin ks))
    {
    $t->hideBlock('new links');
    }
    else
    {
    for ($i=0; $i < count($newlinks ); $i++)
    {
    $t->setCurrentBloc k('newlinks');
    $t->setVariable('U rl', $newlinks[$i]['Url']);
    $t->setVariable('L inkName', stripslashes($n ewlinks[$i]['LinkName']));
    $t->setVariable('D escription', stripslashes($n ewlinks[$i]['Description']));
    $t->parseCurrentBl ock('newlinks') ;
    }
    }

    parseHeader($t, $title);
    parseFooter($t) ;
    $t->show();
    ?>
    [/CODE]

    If someone could please help me it would be GREATLY appreciated.
    Thanks!
    Last edited by Atli; May 21 '07, 07:33 PM. Reason: Added code tags
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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

    Comment

    • deerhide
      New Member
      • May 2007
      • 2

      #3
      didnt work.

      [CODE=text]
      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

      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
      [/CODE]

      my config file,
      [CODE=PHP]
      <?
      // To improve security, chmod 600 this include file - and keep it outside the web-tree:
      require_once '../include/hoo.php';

      $TEMPLATE_FILE = "index_t.ht m"; // Path to the template file
      $SITE_NAME = "Minibike Links"; // Title of the site (keep short)
      $ADMIN_MODE = false; // Set true for admin version
      $SEE_ALL_SUBMIS SIONS = true; // Set false to show submissions in this category only
      $SITE_URL = "http://www.minibiketra der.com"; // Set real URL of site
      $SITE_DIR = "index.php" ; // Appended to SITE_URL for complete address
      $FULL_ADMIN_ACC ESS = true; // True to allow admin to create categories
      $TOP_CAT_NAME = "Top"; // Name of the top "category"
      $ADMIN_EMAIL = "info@minibiket rader.com"; // Admin email address used for new links
      $SMTP_HOSTNAME = "localhost" ;
      $SMTP_LOCALHOST = "127.0.0.1" ;
      $AUTOAPPROVE = false; // True to automatically approve submissions
      $REQUIRE_SUBMIT _EMAIL = false; // True to require email for any submissions
      $SQL_CAT_TBL = "hoo_Categories "; // MySQL table name for the categories table
      $SQL_LNK_TBL = "hoo_Links" ; // MySQL table name for the links table


      // Expand CatID to whole trail
      function breadcrumbs($Ca tID=0)
      {
      global $db;
      global $ADMIN_MODE;
      global $SITE_DIR;

      $db->get_ParentsInt ($CatID);
      $path = $db->TRAIL;
      if(!empty($path ) and $CatID !=0)
      {
      while ( list ( $key,$val ) = each ($path))
      {
      $CatID = stripslashes($v al["CatID"]);
      $CatName = stripslashes($v al["CatName"]);
      if ($CatID == $val["CatID"])
      {
      $trail .= $CatName .':&nbsp;';
      }
      else
      {
      $trail = "<a href=\"$SITE_DI R?viewCat=$CatI D\" class=hoo>$CatN ame</a>:&nbsp;" . $trail;
      }
      }
      }
      else
      {
      $trail = "";
      }
      return "<A HREF=\"$SITE_DI R\" class=\"hoo\">T op</A>: &nbsp;" . $trail;
      }

      function breadcrumbs_txt ($CatID="")
      {
      global $db;
      if(empty($CatID )) { return; }
      $db->get_ParentsInt ($CatID);
      $path = $db->TRAIL;
      if(!empty($path ))
      {
      while ( list ( $key,$val ) = each ($path))
      {
      $CatID = stripslashes($v al["CatID"]);
      $CatName = stripslashes($v al["CatName"]);
      if ($trail) {
      $trail = "$CatName: $trail";
      } else {
      $trail = $CatName;
      }
      }
      } else {
      $trail = "-";
      }
      return $trail;
      }

      // drop-down box for available categories
      function get_cat_selecti on($SelName = "CatID", $IncludeTop = true, $SecSel = 0, $IncludeNone = false)
      {
      global $db;
      global $ADMIN_MODE;
      global $TOP_CAT_NAME;
      $select = "<select name=\"$SelName \">\n";
      if ($IncludeNone)
      {
      if ($SecSel == -1)
      {
      $sel = "selected";
      }
      else
      {
      $sel = "";
      }
      $select .= "<option $sel value=\"NONE\">- none -</option>";
      if ($SecSel == 0)
      {
      $sel = "selected";
      }
      else
      {
      $sel = "";
      }
      $select .= "<option $sel value=\"0\">$TO P_CAT_NAME</option>";
      }
      elseif ($IncludeTop)
      {
      if (($SecSel == 0) or ($SecSel == -1))
      {
      $sel = "selected";
      }
      else
      {
      $sel = "";
      }
      $select .= "<option $sel value=\"0\">$TO P_CAT_NAME</option>";
      }
      $secs = $db->get_AllCats( );
      if(!empty($secs ))
      {
      while (list ($key, $val) = each ($secs))
      {
      // Run for all sections:
      $CatID = $val["CatID"];
      $CatName = breadcrumbs_txt ($CatID);
      if ($CatID == $SecSel)
      {
      $sel = "selected";
      }
      else
      {
      $sel = "";
      }
      $select .= "<option $sel value=\"$CatID\ ">$CatName</option>\n";
      }
      }
      $select .= "</select>\n";
      return $select;
      }

      // Mail the admin anytime a new link is submitted
      function mail_new_link($ postData = "")
      {
      global $db;
      global $ADMIN_EMAIL;

      if( (empty($postDat a)) or (!is_array($pos tData)) ) { return false; }
      if ($ADMIN_EMAIL == "") { return false; }

      $CatID = $postData["CatID"];
      $Url = addslashes(html entities($postD ata["Url"]));
      $Description = addslashes(html entities($postD ata["Descriptio n"]));
      $LinkName = addslashes(html entities($postD ata["LinkName"]));
      $SubmitName = addslashes(html entities($postD ata["SubmitName "]));
      $SubmitEmail = addslashes(html entities($postD ata["SubmitEmai l"]));
      $SubmitDate = time();

      // Get category information
      $CatName = breadcrumbs_txt ($CatID);
      if (empty($CatName )) {
      $CatName = "Unknown";
      }

      $Subject = "New Link: ";
      $Subject .= substr($LinkNam e, 0, 60);
      if ($LinkName != substr($LinkNam e, 0, 60)) {
      $LinkName .= "...";
      }
      $Subject = trim($Subject);

      $Body = "User \"$SubmitNam e\" <".$SubmitEmail ."> submitted this link in category $CatName:\n\n";
      $Body .= "$LinkName at <$Url>\n\n";
      $Body .= "$Description\n \n";
      if ($AUTOAPPROVEQU E) {
      $Body .= "This link was auto-approved.\n";
      } else {
      $Body .= "This link needs approval.\n";
      $Body .= "http://$_SERVER[SERVER_NAME]/links/admin.php\n";
      }

      $From = "$SubmitName<". $SubmitEmail."> ";

      // Send the email notice if email defined
      if ($ADMIN_EMAIL) {
      // function smtp_mail($from , $to, $subject, $body, $replyto = "", $bcc = "")
      smtp_mail($ADMI N_EMAIL, $ADMIN_EMAIL, $Subject, $Body, $From);
      }

      return;
      }
      // Send mail function
      function smtp_mail($from , $to, $subject, $body, $replyto = "", $bcc = "") {
      require('../include/class.phpmailer .php');
      // Prepare SMTP class
      $smtp = new PHPMailer();
      // $smtp->host_name = "localhost" ;
      // $smtp->localhost = "127.0.0.1" ;

      $smtp->From = $from;
      $smtp->AddAddress($to );
      if (!empty($replyt o))
      {
      $smtp->AddReplyTo($re plyto);
      }
      if (!empty($bcc))
      {
      $smtp-AddBCC($bcc);
      }
      $smtp->Subject = $subject;
      $smtp->Body = $body;
      $smtp->IsMail();
      if (!$smtp->Send())
      {
      echo "<p>Could not send the message to $to.\nError: " . $smtp->ErrorInfo . "</p>\n";
      }
      }


      // Print page header based on template file
      function print_header($C atID="",$title= "")
      {
      global $TEMPLATE_FILE;
      global $ADMIN_MODE;
      global $menu;

      $trail = breadcrumbs($Ca tID);
      if ($ADMIN_MODE)
      {
      $trail .= " :<a href=\"admin.ph p?exit_admin=1\ " class=hoo>Exit Admin</a>";
      }

      $filename = $TEMPLATE_FILE;
      $fd = fopen ($filename, "r");
      $c = fread ($fd, filesize ($filename));
      fclose ($fd);

      $c = ereg_replace('@ MENU@', $menu, $c);
      $c = ereg_replace("@ TRAIL@", $trail, $c);
      $c = eregi_replace(" @PHPHOO_BODY@.* ", "", $c);
      print ($c);
      }
      ?>
      [/CODE]
      Last edited by Atli; May 22 '07, 08:23 AM. Reason: Code tags man, code tags!

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        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!)

        Comment

        Working...