Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

& getting added to links when add to cart.


pr0jects

Recommended Posts

Arrggh. Was working totally fine but now it's playing up. I'm not sure what it is that's caused it but i've tried another product_info.php and still nothing. So it's gotta be being parsed into the link incorrectly. Being a nub on php i have no idea how to fix it.

 

The link does work if i go through the category section and i can BUY NOW and it goes into the cart but if i go into the product_info bit then it populates the link incorrectly.

 

 

Works Properly.. .

 

But this. .

 

 

Obviously does'nt work i've worked out the because it's being populated with & instead of just the & - thing is i don't know where it came from or why it suddenly started to happen.

 

I've got to the bit of code in product_info.php

 

                <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>

 

Where it builds the link but i have no idea where to go from here. I presume the link is getting built from various source but how to i find them and debug this.

 

HELPP!! - my clients cannot buy at the moment because of this.

 

Sucks. :)

Link to comment
Share on other sites

@pr0jects

 

First read the forum rules on bumping posts.

 

Have you been using the online file manager to edit files, if so was one of the files includes/functions/html_output.php

 

Then go to includes/functions/html_output.php

 

and check this code

 

  function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
   global $request_type, $session_started, $SID;

   if (!tep_not_null($page)) {
     die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
   }

   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('</td></tr></table></td></tr></table><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($parameters)) {
     $link .= $page . '?' . tep_output_string($parameters);
     $separator = '&';
   } else {
     $link .= $page;
     $separator = '?';
   }

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

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

My apolgizes regarding the bumping i did'nt realise that was a problem but i've got a client for this website and they cannot sell anything so i was desperate. I'm sorry i did'nt realise there was rules for this.

 

As for you saying it might be the wrong code i think i posted the wrong bit. When i'm back in the office in the morning i'll post a clear outline of what's going wrong. I'm not sure why it's happening or why there is that long code at the end of the line. How would i have turned that on? - is that for ssl or something.

 

Thanks for responding. Hoping we can fix it and i can understand it more. Thanks for replying.

Link to comment
Share on other sites

are you saying that it only affects that specific url and does not affect any other link

 

you initially stated

 

http://mysite.biz/shop/product_info.php?cPath=27&products_id=249&action=add_product&osCsid=daa366b8dda9b6982886ab675b838a24

which is a product link, however you then mention

<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>

which is a reviews link that would appear as

 

as an example

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

Sorry yes there was some confusion there on my behalf i must agree. But this is what you get when you dont know what your looking for.

 

Ok, the site is here. (http://hotdecks.biz) If you go there you will noticed that you can select a "music style" and add to your cart using "BUY NOW" but when you actual try to "add to cart" from the product_info.php level it just says product not found.

 

Now i've worked out that some how the url is getting messed up previously before that and it seems that &amp is getting injected into the url incorrectly. I've also noticed that if i click on the add to cart again it just keeps putting in the &amp's again and again.

 

My first question would be how to find the bit of code that creates the URL for the form post (that the add to cart) actually works with? - i found a tep_form thing but have no idea how that gets built.

 

Also, it never used to come up with the osCsid= bit on the end - what have i switched on by mistake for it to do that?

 

I've only really started to get it all working over the last few weeks - the last thing i remember installing was a shipping module but i removed that to see if it was that but it does'nt change anything.

 

Cheers,

Phil.

Link to comment
Share on other sites

Sorry yes there was some confusion there on my behalf i must agree.  But this is what you get when you dont know what your looking for.

 

Ok, the site is here.  (http://hotdecks.biz)  If you go there you will noticed that you can select a "music style" and add to your cart using "BUY NOW" but when you actual try to "add to cart" from the product_info.php level it just says product not found.

 

Now i've worked out that some how the url is getting messed up previously before that and it seems that &amp is getting injected into the url incorrectly.  I've also noticed that if i click on the add to cart again it just keeps putting in the &amp's again and again.

 

My first question would be how to find the bit of code that creates the URL for the form post (that the add to cart) actually works with?  - i found a tep_form thing but have no idea how that gets built.

 

Also, it never used to come up with the osCsid= bit on the end - what have i switched on by mistake for it to do that?

 

I've only really started to get it all working over the last few weeks - the last thing i remember installing was a shipping module but i removed that to see if it was that but it does'nt change anything.

 

Cheers,

Phil.

 

 

you are generating this as your form header in product_info

 

<form name="cart_quantity" action="http://hotdecks.biz/shop/product_info.php?products_id=434&amp;amp;action=add_product&amp;action=add_product&osCsid=2b997b6a909c5c7f75d164ed7dfbe840" method="post">

Treasurer MFC

Link to comment
Share on other sites

Yep that's as far as i got, question is where are the form headers built as it's only then i can find the code that's adding them incorrectly. I'm hoping removing the &amp will sort out the link.

 

Also what is the osCsid bit on the end is that turned on by ssl or something because that never used to be there.

Link to comment
Share on other sites

they are in the includes/functions/html_output.php file

 

<?php
/*
 $Id: html_output.php,v 1.56 2003/07/09 01:15:48 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

////
// The HTML href link wrapper function
 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
   global $request_type, $session_started, $SID;

   if (!tep_not_null($page)) {
     die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
   }

   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('</td></tr></table></td></tr></table><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($parameters)) {
     $link .= $page . '?' . tep_output_string($parameters);
     $separator = '&';
   } else {
     $link .= $page;
     $separator = '?';
   }

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

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
   if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
     if (tep_not_null($SID)) {
       $_sid = $SID;
     } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
       if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
         $_sid = tep_session_name() . '=' . tep_session_id();
       }
     }
   }

   if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
     while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

     $link = str_replace('?', '/', $link);
     $link = str_replace('&', '/', $link);
     $link = str_replace('=', '/', $link);

     $separator = '?';
   }

   if (isset($_sid)) {
     $link .= $separator . $_sid;
   }

   return $link;
 }

////
// 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) . '"';

   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;
 }

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
 function tep_image_submit($image, $alt = '', $parameters = '') {
   global $language;

   $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

   if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

   if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

   $image_submit .= '>';

   return $image_submit;
 }

////
// Output a function button in the selected language
 function tep_image_button($image, $alt = '', $parameters = '') {
   global $language;

   return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);
 }

////
// Output a separator either through whitespace, or with an image
 function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
   return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
 }

////
// Output a form
 function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
   $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';

   if (tep_not_null($parameters)) $form .= ' ' . $parameters;

   $form .= '>';

   return $form;
 }

////
// Output a form input field
 function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
   $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

   if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
     $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
   } elseif (tep_not_null($value)) {
     $field .= ' value="' . tep_output_string($value) . '"';
   }

   if (tep_not_null($parameters)) $field .= ' ' . $parameters;

   $field .= '>';

   return $field;
 }

////
// Output a form password field
 function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
   return tep_draw_input_field($name, $value, $parameters, 'password', false);
 }

////
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
 function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
   $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

   if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';

   if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
     $selection .= ' CHECKED';
   }

   if (tep_not_null($parameters)) $selection .= ' ' . $parameters;

   $selection .= '>';

   return $selection;
 }

////
// Output a form checkbox field
 function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
   return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
 }

////
// Output a form radio field
 function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
   return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);
 }

////
// Output a form textarea field
 function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
   $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';

   if (tep_not_null($parameters)) $field .= ' ' . $parameters;

   $field .= '>';

   if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
     $field .= stripslashes($GLOBALS[$name]);
   } elseif (tep_not_null($text)) {
     $field .= $text;
   }

   $field .= '</textarea>';

   return $field;
 }

////
// Output a form hidden field
 function tep_draw_hidden_field($name, $value = '', $parameters = '') {
   $field = '<input type="hidden" name="' . tep_output_string($name) . '"';

   if (tep_not_null($value)) {
     $field .= ' value="' . tep_output_string($value) . '"';
   } elseif (isset($GLOBALS[$name])) {
     $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
   }

   if (tep_not_null($parameters)) $field .= ' ' . $parameters;

   $field .= '>';

   return $field;
 }

////
// Hide form elements
 function tep_hide_session_id() {
   global $session_started, $SID;

   if (($session_started == true) && tep_not_null($SID)) {
     return tep_draw_hidden_field(tep_session_name(), tep_session_id());
   }
 }

////
// Output a form pull down menu
 function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
   $field = '<select name="' . tep_output_string($name) . '"';

   if (tep_not_null($parameters)) $field .= ' ' . $parameters;

   $field .= '>';

   if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

   for ($i=0, $n=sizeof($values); $i<$n; $i++) {
     $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
     if ($default == $values[$i]['id']) {
       $field .= ' SELECTED';
     }

     $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';
   }
   $field .= '</select>';

   if ($required == true) $field .= TEXT_FIELD_REQUIRED;

   return $field;
 }

////
// Creates a pull-down list of countries
 function tep_get_country_list($name, $selected = '', $parameters = '') {
   $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
   $countries = tep_get_countries();

   for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
     $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
   }

   return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 }
?>

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

they are in the includes/html_output.php file

 

Well that file in includes/functions/ (wrong place btw) i have'nt changed. And to double check i downloaded a fresh copy and overwrote this one and tested it again.

 

Still same problem, somehow the url is getting populated with those &amp things still. Also how do i stop the osCid code thing?

Link to comment
Share on other sites

Yep that's as far as i got, question is where are the form headers built as it's only then i can find the code that's adding them incorrectly.    I'm hoping removing the &amp will sort out the link.

 

Also what is the osCsid bit on the end is that turned on by ssl or something because that never used to be there.

 

 

don't say you never saw a session id before because then I start to shake.

 

IF you have a DEFAULT html_output for generating the links then there must be something not correct in your php.ini file. Do you have access to that one ?

Treasurer MFC

Link to comment
Share on other sites

don't say you never saw a session id before because then I start to shake.

 

Lol. No i've seen the session id before but i'm concered about the fact as to why it's suddently using them i dont remember switching on anything to do with session id's. We had some help with getting the sample player osplayer in there but i remember that the basket was working then.

 

IF you have a DEFAULT html_output for generating the links then there must be something not correct in your php.ini file. Do you have access to that one ?

 

Can't see how it would be the php.ini file but i'll ask if i can find it. If not get a link to a php info page so you look at that.

Link to comment
Share on other sites

don't say you never saw a session id before because then I start to shake.

 

Lol.  No i've seen the session id before but i'm concered about the fact as to why it's suddently using them i dont remember switching on anything to do with session id's.  We had some help with getting the sample player osplayer in there but i remember that the basket was working then.

 

IF you have a DEFAULT html_output for generating the links then there must be something not correct in your php.ini file. Do you have access to that one ?

 

Can't see how it would be the php.ini file but i'll ask if i can find it.  If not get a link to a php info page so you look at that.

 

Ofcourse you have seen the sesson id's but ofcourse they only show when not registered in cookies so sometimes they show and sometimes they do not.

 

I am a little confused about you second section, how can't you see that it is not the php.ini file if you are not sure whether you can find it ?

 

simple check, what are your other links doing ? do they also generate &amp stuff or is this just via 1 isolated form submit ?

I.E. some tracing would enlighten.

Treasurer MFC

Link to comment
Share on other sites

I am a little confused about you second section, how can't you see that it is not the php.ini file if you are not sure whether you can find it ?

 

Well let me clear this up for you so your absolulty clear. I used to host all our clients sites on our webbox in the uk but i've moved a lot of clients to our usa host and obviously i dont have that low level access to php.ini - i can probably get a phpinfo. The reason why i say it's not the php.ini is because it USED to work. you could add things into the cart etc from the product info section. It's always work but then for some reason recently it's not worked. The only thing i can remember changing (my fault for not documenting changes) is adding in a module for pricing and meta tag generation on the pages. Obviously somewhere it's b0rked it but i have no idea where.

 

So it's not a case of finding the php.ini, it's a case of i dont think they will allow me access to it. What do you need me to find in the php.ini - i might be able to ask them to see if a certain function is set or not.

 

simple check, what are your other links doing ? do they also generate &amp stuff or is this just via 1 isolated form submit ? I.E. some tracing would enlighten.

 

Ok, basically at the moment the links from the music styles section work properly, in that if i select "BUY NOW" that item will get put into the cart. But if i then click on the link for the product information and then "add to cart" the page refreshs and returns back to the same information page. The link that it has built for the form submit is already wrong btw when you get to this page. Once you click on the add to cart it adds in more &amp into the url at the top.

 

For instance, if i go to a product the form link on that page as already been populated like this.

 

http://hotdecks.biz/shop/product_info.php?...7e09b6c47072605

 

i pretty sure the &amp should not be ther, the link should probably be..

 

http://hotdecks.biz/shop/product_info.php?...7e09b6c47072605

 

But when i run that link i get. . "Your Shopping Cart is empty!" :blink:

 

It's doing it on all products at the moment, not just on one.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...