the44chris
Programmer
We are having a problem with adding products into our portfolio only in IE. In firefox it works great, but in IE clicking the “add to portfolio” button on product pages yields no results besides an “error on page” notification. The error reads…
Line: 42
Char: 5
Error: Object doesn’t support this property or method
Code: 0
URL: points to our order_page.pl with a reference to the specific product
A basic rundown of how our portfolio functions…
Product pages are dynamically generated with an order_page.pl perl script. On the product page there is a link to add the product to a portfolio, which is handled by a show_favorites.pl perl script. I don’t know in which perl script the error resides.
I have tried setting all ie security preferences to the absolute bare minimum and the problem still exists.
Any help in determining how to fix this problem would be greatly appreciated.
The code for the order_page.pl script(doubt you need the template files too):
for the show_favorites.pl page……..
Line: 42
Char: 5
Error: Object doesn’t support this property or method
Code: 0
URL: points to our order_page.pl with a reference to the specific product
A basic rundown of how our portfolio functions…
Product pages are dynamically generated with an order_page.pl perl script. On the product page there is a link to add the product to a portfolio, which is handled by a show_favorites.pl perl script. I don’t know in which perl script the error resides.
I have tried setting all ie security preferences to the absolute bare minimum and the problem still exists.
Any help in determining how to fix this problem would be greatly appreciated.
The code for the order_page.pl script(doubt you need the template files too):
Code:
#!/usr/bin/perl -w
require '.pm';
use CGI;
use CGI::Carp 'fatalsToBrowser';
use DBI;
$dbh = DBI->connect("dbi:mysql:", "", "", { RaiseError => 1});
$cgq = new CGI;
print "Content-type: text/html\n\n";
my $photo_id = $cgq->param('photo_id');
if (!$photo_id) {
print "<HTML><HEAD><TITLE>Error</TITLE></HEAD>";
print "<BODY>I'm sorry, but a photo_id is required...</BODY></HTML>";
exit();
}
my %prices;
sub hashValueAscendingNum {
$prices{$a} <=> $prices{$b};
}
my $sth = $dbh->prepare("select * from _tmp where photo_id='$photo_id'");
$sth->execute();
my $results = $sth->fetchrow_hashref();
$params{'photo_id'} = $photo_id;
$params{'_name'} = $results->{'name'};
$params{'category'} = $results->{'category'};
$params{'material'} = $results->{'material'};
$params{'quality'} = $results->{'quality'};
$params{'made_in'} = $results->{'made_in'};
$params{'collection'} = $results->{'collection'};
$params{'description'} = $results->{'description'};
$params{'descr2'} = $results->{'descr2'};
$params{'designer'} = $results->{'made_in'};
$params{'picture'} = $results->{'picture'};
$params{'large_pic'} = $results->{'large_pic'};
$params{'keywords'} = "".$results->{'name'}.", ".$results->{'category'}.", ".$results->{'material'}.", ".$results->{'quality'}.", ".$results->{'made_in'}.", ".$results->{'collection'};
$params{'meta_description'} = $results->{'description'};
$params{'meta_description'} =~ s/[\n\r"]//g;
print_tpl("template/order_page_top.tpl", "", %params);
my $sth2 = $dbh->prepare("select name, category, cart2.photo_id from cart as cart1, cart as cart2,_tmp where cart1.photo_id='$photo_id' and cart1.cart_id = cart2.cart_id and _tmp.photo_id = cart2.photo_id and cart2.photo_id!='$photo_id' group by 1 limit 3;");
#$sth2->execute();
if (0 && $sth2->rows) {
print <<ENDHTML;
<tr>
<td colspan="4" bgcolor="#990000">
<font color=#ffffff face="Verdana, Arial, Helvetica" size="1"> <b>Others who bought this item has also bought...
</font>
</td>
</tr>
ENDHTML
}
my $old_photo_id = $cgq->param('photo_id');
while (0 && (my $row_arr = $sth2->fetchrow_hashref())) {
$cgq->param('photo_id', $row_arr->{'photo_id'});
print "<tr>";
print "<td><font color=#000000 face=\"Verdana, Arial, Helvetica\" size=\"2\"><b><a href=\"".$cgq->self_url()."\">".$row_arr->{'name'}."</a></b></font></td>";
print "<td><font color=#000000 face=\"Verdana, Arial, Helvetica\" size=\"2\"><b>".$row_arr->{'category'}."</b></font></td>";
print "</tr>";
}
$cgq->param('photo_id', $old_photo_id);
$_name = $params{'_name'};
print <<ENDHTML;
<tr>
<td colspan="4" height="60" bgcolor="#990000">
<p><font
color=#ffffff face="Verdana, Arial, Helvetica" size="1"> <b>Product
Shown: </b></font><font face="Verdana, Arial, Helvetica" size="2" color="#FFCC33"><b>
"$_name" </b></font><font
color=#ffffff face="Verdana, Arial, Helvetica"><br>
</font></p>
<p> </p>
</td>
</tr>
ENDHTML
print "<input type=\"hidden\" name=\"photo_id\" value=\"".$cgq->param('photo_id')."\">";
if (!$cgq->param('action')) {
print "<input type=\"hidden\" name=\"action\" value=\"add_\">";
}
for(my $i=1; $i<=15; $i++) {
my $size = $results->{"size$i"};
my $price = $results->{"price$i"};
$prices{$size} = scalar $price;
$prices_loc{$size} = scalar $i;
if (($prices{$size}) && ($results->{'sale'})) {
$prices_sale{$size} = calculate_sale($price, $results->{'sale'});
}
}
my $price_count = 0;
foreach $size (sort hashValueAscendingNum (keys(%prices))) {
if ($size) {
$price_count++;
print "<tr bgcolor=\"#faf2e0\">";
print "<td width=\"210\" height=\"2\"><font color=\"#000000\" face=\"arial, verdana, helvetica, sans-serif\" size=\"2\"><b>$size</b></font></td>";
print <<ENDHTML;
<td colspan="3" width="120" bgcolor="#faf2e0" height="2"><font
face="arial, verdana, helvetica, sans-serif"
size=2>
ENDHTML
print "<input name=\"option_value\" class=\"sizeRadioSelect\" type=\"radio\" rel=\"$size\" value=\"".$prices_loc{$size}." \"".($price_count == 1?" checked":"").">";
if ($prices_sale{$size}) {
print "<font color=#990000 face=\"arial, verdana, helvetica, sans-serif\"><b>\$".$prices_sale{$size}."</font> <font face=\"arial, verdana, helvetica, sans-serif\"><strike>";
}
print "\$$prices{$size}</font></strike></b></td></tr>";
}
}
if ($params{'large_pic'} && (-e "/home//[URL unfurl="true"]www/".$params{'large_pic'}))[/URL] {
$params{'large_pic_code'} = $params{'large_pic'};
} else {
$params{'large_pic_code'} = $params{'picture'};
}
$params{"self_url"} = $cgq->self_url();
print_tpl("template/order_page_bottom.tpl", "", %params);
for the show_favorites.pl page……..
Code:
#!/usr/bin/perl -w
require '.pm';
use CGI;
use CGI::Carp 'fatalsToBrowser';
use DBI;
connect_db();
$cgq = new CGI;
$showFrame = TRUE;
my $user_id = check_login();
if (!$user_id) {
print $cgq->header(-status=>"302 Moved", -location=>"/Signin.htm?finish=".$cgq->self_url());
exit;
}
print "Content-type: text/html\n\n";
if (($cgq->param('action') eq "delete") && ($cgq->param('fav_id') ne "")) {
$dbh->do("delete from favs where user_id='".$user_id."' and id='".$cgq->param('fav_id')."'");
} elsif (($cgq->param('action') eq "add") && ($cgq->param('photo_id') ne "")) {
$dbh->do("insert into favs set user_id='".$user_id."', photo_id='".$cgq->param('photo_id')."', size=".$dbh->quote($cgq->param('size')));
} elsif (($cgq->param('action') eq "update")) {
$totalRows = $cgq->param('rowCount');
$result = TRUE;
$runQuery = FALSE;
for($i=1;$i<=$totalRows;$i++) {
$rowFavID = $cgq->param('favID' . $i);
$rowComment = $dbh->quote($cgq->param('rowComment' . $i));
$rowQty = $cgq->param('rowQty' . $i);
$rowSize = $dbh->quote($cgq->param('rowSize' . $i));
$rowRemove = $cgq->param('removeID' . $i);
if ($rowRemove) {
$query = "delete from favs";
$runQuery = TRUE;
} else {
if (($rowComment ne "''") || ($rowSize ne "''") || ($rowQty ne "")) {
$query = "update favs set";
if ($rowComment ne "''") {
$query = $query . " comment=".$rowComment;
}
if ($rowQty) {
if ($rowComment ne "''") {
$query = $query . ",";
}
$query = $query . " qty='" . $rowQty . "'";
}
if ($rowSize ne "''") {
if ($rowComment ne "''" || $rowQty) {
$query = $query . ",";
}
$query = $query . " size=".$rowSize;
}
$runQuery = TRUE;
}
}
if ($runQuery) {
$query = $query . " where id='".$rowFavID."'";
$locResult = $dbh->do($query);
if (!$locResult) {
$result = FALSE;
}
}
}
if ($result) {
print "{'response':'1', 'message':'Update succesfull.', 'query':".$printQuery."}";
} else {
print "{'response':'0', 'message':'Failed to update.'}";
}
exit();
}
$query_sizes = "";
for($i=1;$i<15;$i++) {
$query_sizes = $query_sizes."size".$i.", ";
}
$query = "select _tmp.photo_id, favs.id as fav_id, favs.qty as fav_qty, favs.size as fav_size, favs.comment as fav_comment, name, category, collection, ".$query_sizes." thumb_pic from _tmp, favs where _tmp.photo_id=favs.photo_id and favs.user_id=$user_id";
my $sth = $dbh->prepare($query);
$sth->execute();
$params{'rowCount'} = $sth->rows();
if ($showFrame) {
print_tpl("template/portfolio_top.tpl", "", %params);
}
$x = 1;
while (my $row_arr = $sth->fetchrow_hashref) {
$params{'rowID'} = $x;
$params{'fav_id'} = $row_arr->{'fav_id'};
$params{'photoID'} = $row_arr->{'photo_id'};
$params{'thumbnail'} = $row_arr->{'thumb_pic'};
$params{'itemName'} = $row_arr->{'name'};
$params{'itemCategory'} = $row_arr->{'category'};
$params{'itemCollection'} = $row_arr->{'collection'};
$params{'itemSize'} = $row_arr->{'fav_size'};
$params{'rowQTY'} = $row_arr->{'fav_qty'};
$params{'rowComment'} = $row_arr->{'fav_comment'};
if ($params{'rowComment'} eq "") {
$params{'rowComment'} = "Click here to add a comment...";
}
$itemSizeOptions = "";
for($i=1;$i<15;$i++) {
if (!($row_arr->{'size'.$i} eq "")) {
if ($row_arr->{'size'.$i} eq $row_arr->{'fav_size'}) {
$itemSizeSelected = ' selected="selected"';
} else {
$itemSizeSelected = "";
}
$itemSizeOptions = $itemSizeOptions . "<option".$itemSizeSelected.">".$row_arr->{'size'.$i}."</option>\n";
}
}
$params{'itemSizeOptions'} = $itemSizeOptions;
print_tpl("template/portfolio_item.tpl", "", %params);
$x++;
}
if ($showFrame) {
print_tpl("template/portfolio_bottom.tpl");
}