Jump to content

Parse error: parse error, unexpected '\"'


Recommended Posts

I am writing a script for dynamic links and images. I have based it on osCommerce 2.2 MS2. I get this prase error:
Parse error: parse error, unexpected '\"' in /home/beachgla/public_html/top.php on line 103

Here is the code of top.php
[code]<?php
/*
    Eddie Schnell
    Beach Glass Direct.com
*/

// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  if (function_exists("ini_get")) {
    ini_get("register_globals") or exit("Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.");
  }

// server variables
  define("HTTP_SERVER", "http://beachglassdirect.com");
  define("HTTPS_SERVER", "https://host274.ipowerweb.com/~beachgla");
  define("ENABLE_SSL", true);
  define("HTTP_COOKIE_DOMAIN", "beachglassdirect.com");
  define("HTTPS_COOKIE_DOMAIN", "host274.ipowerweb.com");
  define("HTTP_COOKIE_PATH", "/");
  define("HTTPS_COOKIE_PATH", "/");
  define("DIR_WS_HTTP_CATALOG", "/");
  define("DIR_WS_HTTPS_CATALOG", "/");
  define("DIR_WS_FORMS", "forms/");
  define("DIR_WS_OASIS", "oasis/");
  define("DIR_WS_CATALOG", "catalog/");
  define("DIR_FS_SITE", "/home/beachgla/public_html/");
  
// set the type of request (secure or not)
  $request_type = (getenv("HTTPS") == "on") ? "SSL" : "NONSSL";

// set php_self in the local scope
  if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"];

  if ($request_type == "NONSSL") {
    define("DIR_WS_CATALOG", DIR_WS_HTTP_CATALOG);
  } else {
    define("DIR_WS_CATALOG", DIR_WS_HTTPS_CATALOG);
  }

// define filenames
  define("FILENAME_DEFAULT", "index.php");
  define("FILENAME_CONTACT", "contact.php");
  define("FILENAME_DEALER_IDEA", "dealer-idea.php");
  define("FILENAME_GLASS", "glassbyounce.php");
  define("FILENAME_INFO", "info.php");
  define("FILENAME_JEWELRY", "jewelry.php");
  define("FILENAME_NET_RE_DIR", "net.php");
  define("FILENAME_OASIS_HOME", "oasis.php");
  define("FILENAME_ORNAMENTS", "ornaments.php");
  define("FILENAME_TELL_A_FRIEND", "tellafriend.php");
  define("FILENAME_OASIS_AGELESS_CAPS", "ageless.php");
  define("FILENAME_OASIS_AGELESS_PRIME", "agelessprime.php");
  define("FILENAME_OASIS_AGELESS_XTRA", "agelessxtra.php");
  define("FILENAME_OASIS_CP", "convenience.php");
  define("FILENAME_OASIS_CP_PRICE", "convenience_price.php");
  define("FILENAME_OASIS_DR", "dr.php");
  define("FILENAME_OASIS_FUNC_FOODS", "foods.php");
  define("FILENAME_OASIS_INTHINITY", "inthinity.php");
  define("FILENAME_OASIS_REGENICARE", "regenicare.php");
  define("FILENAME_FORMS_DEALER", "bd.php");
  define("FILENAME_FORMS_CONTACT", "contact.php");
  define("FILENAME_FORMS_CP", "convenience.php");
  define("FILENAME_FORMS_IDEAS", "ideas.php");
  
// The HTML href link wrapper function
  function tep_href_link($page = "", $parameters = "", $connection = "NONSSL") {
    global $request_type, $session_started, $SID;
    
        if ($connection == "NONSSL") {
      $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
    } elseif ($connection == "SSL") {
      if (ENABLE_SSL == true) {
        $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
      } else {
        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
      }
    } else {
      die("<br><br><font color=\"#ff0000\"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>");
  
    if (!tep_not_null($page)) {
      die("<br><br><font color=\"#ff0000\"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>");
}

    if (tep_not_null($parameters)) {
      $link .= $page . "?" . tep_output_string($parameters);
      $separator = "&";
    } else {
      $link .= $page;
      $separator = "?";
    }

    while ( (substr($link, -1) == "&") || (substr($link, -1) == "?") ) $link = substr($link, 0, -1);

////
// The HTML image wrapper function
  function tep_image($src, $alt = "", $width = "", $height = "", $parameters = "") {
    if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == "false") ) {
      return false;
    }

// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
    $image = ("<img src="" . tep_output_string($src) . "" border="0" alt="" . tep_output_string($alt) . """); LINE 103
}
    if (tep_not_null($alt)) {
      $image .= " title=" " . tep_output_string($alt) . " "";
    }

    if ( (CONFIG_CALCULATE_IMAGE_SIZE == "true") && (empty($width) || empty($height)) ) {
      if ($image_size = @getimagesize($src)) {
        if (empty($width) && tep_not_null($height)) {
          $ratio = $height / $image_size[1];
          $width = $image_size[0] * $ratio;
        } elseif (tep_not_null($width) && empty($height)) {
          $ratio = $width / $image_size[0];
          $height = $image_size[1] * $ratio;
        } elseif (empty($width) && empty($height)) {
          $width = $image_size[0];
          $height = $image_size[1];
        }
      } elseif (IMAGE_REQUIRED == "false") {
        return false;
      }
    }

    if (tep_not_null($width) && tep_not_null($height)) {
      $image .= " width="" . tep_output_string($width) . "" height="" . tep_output_string($height) . """;
    }

    if (tep_not_null($parameters)) $image .= " " . $parameters;

    $image .= ">";

    return $image;
  }

// set the cookie domain
  $cookie_domain = (($request_type == "NONSSL") ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
  $cookie_path = (($request_type == "NONSSL") ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/9554-parse-error-parse-error-unexpected/
Share on other sites

You must escape your quotes! Change

[code]$image = ("<img src="" . tep_output_string($src) . "" border="0" alt="" . tep_output_string($alt) . """);[/code]

to

[code]$image = ("<img src=\"" . tep_output_string($src) . "\" border=\"0\" alt="\" . tep_output_string($alt) . "\"");[/code]
Now I get this:
[code]Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/beachgla/public_html/top.php on line 103

Parse error: parse error, unexpected '\"' in /home/beachgla/public_html/top.php on line 103[/code]
  • 1 month later...
Just correct your code,

from this
[code]$image = ("<img src="" . tep_output_string($src) . "" border="0" alt="" . tep_output_string($alt) . """);[/code]
to this
[code]$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';[/code]

from this
[code]$image .= " title=" " . tep_output_string($alt) . " "";[/code]
to this
[code]$image .= ' title=" ' . tep_output_string($alt) . ' "';[/code]

from this
[code]$image .= " width="" . tep_output_string($width) . "" height="" . tep_output_string($height) . """;[/code]
to this
[code]$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';[/code]

You also have some error with { } messed up, correct them too. And be ware with OsCommerce modifications in future :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.