Jump to content

Weird Issue with PHP code


diggysmalls

Recommended Posts

Hi.  I must warn you that I know very little.  I have taken over the responsibilities of our former web admin and we appear to have an issue with one of our sites (we are a trailer manufacturer).  I don't know when it happened, however, it appears that a lot of pages don't appear to work properly.  For example, when a product page loads, the URL appears to change, however the page stays the same.  The site is www.bensonproducts.com.  I have looked at the code in Dreamweaver and see where some variables are missing, but I don't really know how the data is supposed to be fed to the other pages.

 

Any advice or help is greatly appreciated.

 

Thank you.

 

[attachment deleted by admin]

Link to comment
Share on other sites

I too looked at the products page and see that it doesn't work properly in Safari [Mac] in that the products aren't displayed. I think it may be the same problem I just encountered when moving a site to a host with PHP v. 5+. In my php code I was getting the variable value passed in the url string which would decide what content to display on the page. To get the value from the your URL it seems you must use:

$YourVarName=$_GET['cSPag'];

. It would help to post a bit of the PHP code.

Link to comment
Share on other sites

It seems to be loading for me; this may be a browser compatibility issue. What browser are you using?

 

Also, I can't seem to open your attachment on my system; it is a large file?

* Additional Info.doc (0 kB - downloaded 2 times.)

 

Took me half an hour on a T1 to download that baby.

Link to comment
Share on other sites

I again apologize for my lack of knowledge.  We bought this company and the site was already up and running (not built by us) and our previous web admin knew just enough PHP.  I am an SAP ABAP developer, with some web skills, but PHP is out of my knowledge base (although I understand the code, I don't know how PHP 'works').

 

Here is a bit of the code:

This is the code for the page that is first displayed (first image in attachment):

<?

include ("inc_page_header.php");

?>

 

<?

$cPPag = "Products";

if (($cSPag == "") || (!isset($cSPag)) )

{

$cSPag = "ProductsNew";

}

if ($cSSPag == "")

{

$strSQL = "SELECT * FROM tbl_content WHERE `page_Name` = '".$cSPag."'";

}

else

{

$strSQL = "SELECT * FROM tbl_content WHERE `page_Name` = '".$cSSPag."'";

}

$result = mysql_db_query ($dbName, $strSQL, $dbConn);

if    (!$result) { $set = "SQL"; $ses = $strSQL; include("../__inc_Error.php");}   

$rows_Returns =  mysql_num_rows($result);

if ($rows_Returns > 0 )

{

    $row = mysql_fetch_array($result);

    $page_Name = trim($row['page_Name']);

    $page_Title = trim($row['page_Title']);

    $Page_Type = trim($row['Page_Type']);

    $page_Grouping = trim($row['page_Grouping']);

    $Page_Header_Image = trim($row['Page_Header_Image']);

    $Page_Small_Image = trim($row['Page_Small_Image']);

    $Page_Content = trim($row['Page_Content']);

    $Page_HotTopic_Right = trim($row['Page_HotTopic_Right']);

    $Page_HotTopic_Left = trim($row['Page_HotTopic_Left']);

    $Page_Detail_Listing = trim($row['Page_Detail_Listing']);

    $Page_Mulitple_Items = trim($row['Page_Mulitple_Items']);

   

}

 

if ($Page_Small_Image != "" )

{

    $image_Border_Shadow = "/CmUp/Images/ShadowBox/".$Page_Small_Image;

}

else

{

    $image_Border_Shadow = "";

}

$Page_Title = $page_Title;

 

if ($cSPag == "ProductsNew")

{

if ($cSSPag == "")

{

$bucketName = "NEW";

include("inc_random_image.php");

$headerImage = $strRandImage;

}

else

{

switch ($cSSPag)

{

case "NewDumpTrailers":

$bucketName = "DT";

break;

case "NewPlatformTrailers":

$bucketName = "PT";

break;

case "NewDumpBodies":

$bucketName = "DB";

break;

case "NewPlatformBodies":

$bucketName = "PB";

break;

}

include("inc_random_image.php");

$headerImage = $strRandImage;

}

}

else

{

if ($Page_Header_Image != "" )

{

$headerImage = "/CmUp/Images/Headers/".$Page_Header_Image;

}

}

 

 

$hotspot_Right = $Page_HotTopic_Right;

?>

 

 

<TABLE cellpadding="0" cellspacing="0" width="737">

    <TR>

        <!-- BEGIN Nav Bar-->

        <TD width="162" valign="top">

            <? include("inc_navagation_Bar.php");?></TD>

        <TD width="575" valign="top"  >

            <TABLE width="575" cellpadding="0" cellspacing="0" border="0" >

                <?

                include("inc_template_Header_Image.php");

                ?>

                <TR>

                    <TD valign="top" style="background-image:url(images/bg_home_Content_Base.gif); background-position:left; background-repeat:repeat-y;" >

                        <TABLE width="575" cellpadding="0" cellspacing="0" border="0" >

                            <TR>

                                <TD rowspan="2" width="18"><IMG src="images/spacer.gif" height="190" width="18"></TD>

                                <TD valign="top" height="41" colspan="3" width="504" style="background-image:url(images/bg_Page_Titles.jpg)" >

                                    <TABLE cellpadding="0" cellspacing="0" height="41" colspan="3" width="504" class="pageHeader" >

                                        <TR><TD height="5"><IMG src="images/spacer.gif" width="504" height="5"></IMG></TD></TR>

                                        <TR><TD class="pageHeader" valign="top"><?=$Page_Title?></TD></TR>

                                    </TABLE></TD>

                                <TD rowspan="2" width="53" height="100%" valign="top" >

                                    <SCRIPT language="javascript" src="flash/content_Right_Filler.js"></SCRIPT></TD>

                            </TR>

                            <TR>

                                <TD valign="top" class="contentText" height="200">

                                    <?

                                        include ("inc_navagation_Bar_Sub.php");

                                    ?>

                                    <?=$Page_Content?>

                                    </TD>

                                <TD width="28"><IMG src="images/spacer.gif" width="28"></TD>

                                <TD width="116" valign="top" class="contentText">

                                    <?

                                    //    $image_Border_Shadow

                                        include ("inc_image_border_shadow.php");

                                    ?>

                                    <?

                                    //    $hotspot_Right

                                        include ("inc_template_HotSpot_RightSide.php");

                                    ?>

                            </TR>

                        </TABLE></TD>

                </TR>

<?

include ("inc_page_footer.php");

?>

 

-----------------------------------------------------------------------

Now...this is the code on the products detail pages (where I presume production information should show based on type of product clicked):

 

<?

include ("inc_page_header.php");

?>

 

<?

 

$id = trim($id);

$cPPag = "Products";

$strSQL = "SELECT Product_Spec_Sheet, `pk_Product_ID`, `Product_Type`, `Product_Category`, `Product_Style`, `Product_Name`, `Product_img_Header`, `Product_img_Thumbnail`, `Product_flash_Detail`, `Product_Content`, `Product_Status` FROM `tbl_products` WHERE `pk_Product_ID` = '$id'";

 

$result = mysql_db_query ($dbName, $strSQL, $dbConn);

if    (!$result) { $set = "SQL"; $ses = $strSQL; include("../__inc_Error.php");}   

$rows_Returns =  mysql_num_rows($result);

if ($rows_Returns > 0 )

{

    $row = mysql_fetch_array($result);

    $pk_Product_ID = trim($row['pk_Product_ID']);

    $Product_Type = trim($row['Product_Type']);

    $Product_Category = trim($row['Product_Category']);

    $Product_Style = trim($row['Product_Style']);

    $Product_Name = trim($row['Product_Name']);

    $Product_img_Header = trim($row['Product_img_Header']);

    $Product_img_Thumbnail = trim($row['Product_img_Thumbnail']);

    $Product_flash_Detail = trim($row['Product_flash_Detail']);

    $Product_Content = trim($row['Product_Content']);

    $Product_Spec_Sheet = trim($row['Product_Spec_Sheet']);

   

}

 

if ($Product_img_Thumbnail != "" )

{

$image_Border_Shadow = "/CmUp/Images/ShadowBox/".$Product_img_Thumbnail;

}

else

{

$image_Border_Shadow = "";

}

 

if ($Product_Spec_Sheet != "" )

{

$Product_Spec_Sheet = "/CmUp/Media/".$Product_Spec_Sheet;

}

 

 

 

$Page_Title = $Product_Name;

 

if ($Product_img_Header != "" )

{

$headerImage = "/CmUp/Images/Headers/".$Product_img_Header;

}

$hotspot_Right = "";

?>

 

 

<TABLE cellpadding="0" cellspacing="0" width="737">

    <TR>

        <!-- BEGIN Nav Bar-->

        <TD width="162" valign="top">

            <? include("inc_navagation_Bar.php");?></TD>

        <TD width="575" valign="top"  >

            <TABLE width="575" cellpadding="0" cellspacing="0" border="0" >

<?

if ($Product_flash_Detail != "")

{

?><SCRIPT language="javascript" src="flash/<?=$Product_flash_Detail?>"></SCRIPT><?

}

else

{

include("inc_template_Header_Image.php");

}

?>

                <TR>

                    <TD valign="top" style="background-image:url(images/bg_home_Content_Base.gif); background-position:left; background-repeat:repeat-y;" >

                        <TABLE width="575" cellpadding="0" cellspacing="0" border="0" >

                            <TR>

                                <TD rowspan="2" width="18"><IMG src="images/spacer.gif" height="190" width="18"></TD>

                              <? if ($Product_flash_Detail == "")  {?>

<TD valign="top" height="41" colspan="3" width="504" style="background-image:url(images/bg_Page_Titles.jpg)" >

                                    <TABLE cellpadding="0" cellspacing="0" height="41" colspan="3" width="504" class="pageHeader" >

                                        <TR><TD height="5"><IMG src="images/spacer.gif" width="504" height="5"></IMG></TD></TR>

                                        <TR><TD class="pageHeader" valign="top"><?=$Page_Title?></TD></TR>

                                    </TABLE></TD>

<? } else {?>

<TD valign="top" height="1" colspan="3" width="504"><IMG src="images/spacer.gif" width="504" height="1"></IMG></TD>

<? }?>

                                <TD rowspan="2" width="53" height="100%" valign="top" >

                                    <SCRIPT language="javascript" src="flash/content_Right_Filler.js"></SCRIPT></TD>

                            </TR>

<TR>

<TD valign="top" class="contentText" height="200">

<?

include ("inc_navagation_Bar_Sub.php");

?>

<?=$Product_Content?>

</TD>

<TD width="28"><IMG src="images/spacer.gif" width="28"></TD>

<TD width="116" valign="top" class="contentText">

<?

//    $image_Border_Shadow

include ("inc_image_border_shadow.php");

?>

                                   

<SPAN class="subsubNavagationReg">»</SPAN>  <A href="page_products_specs.php?id=<?=$id?>&cSPag=<?=$cSPag?>&cSSPag=<?=$cSSPag?>">Specifications</A><BR />

 

<? if ($id==8 || $id==13 || $id==2 || $id==6)

{?>

<BR />

<? }

else {?>

<SPAN class="subsubNavagationReg">»</SPAN>  <A target="_blank" href="<?=$Product_Spec_Sheet?>">Download PDF</A><BR />

<? }

?>

                                                                       

<?

//    $hotspot_Right

include ("inc_template_HotSpot_RightSide.php");

?>

</TR>

                        </TABLE></TD>

                </TR>

<?

include ("inc_page_footer.php");

?>

Link to comment
Share on other sites

Diggy,

 

I think the way the code gets the values from the URL is suspect. At the top of the code block, try:

<?
if(isset($GET_[cSPag])) {    // This line prevents a php error if  var cSPag is not in the URL
     $cSPag = $GET_[cSPag];
}

$cPPag = "Products";               // This is where your code starts.
if (($cSPag == "") || (!isset($cSPag)) )
{

 

You'll have to do this for the cSSPag var as well.

 

Good Luck!

 

Irvin. <><

Link to comment
Share on other sites

Thanks for the reply, Irvin.  I added that code to the top and the following errors displayed at the bottom of the page:

 

PHP Notice: Use of undefined constant cSPag - assumed 'cSPag' in E:\wwwroot\bensonproducts.com\page_products.php on line 7 PHP Notice: Use of undefined constant cSSPag - assumed 'cSSPag' in E:\wwwroot\bensonproducts.com\page_products.php on line 11

Link to comment
Share on other sites

Irvin forgot the quotes in

 

if(isset($GET_[cSPag])) {    // This line prevents a php error if  var cSPag is not in the URL

    $cSPag = $GET_[cSPag]

 

should be

 

if(isset($_GET['cSPag'])) {    // This line prevents a php error if  var cSPag is not in the URL

    $cSPag = $_GET['cSPag']

Link to comment
Share on other sites

The simple fact is that your code is old and probably utilizes global variables which have been switched off since php 5. If your host has switched versions of php then this is your issue. You can re-activate using a .htacces file and adding the line:

php_flag register_globals on

However, this was stripped out of php for a reason. It is a massive security risk. For that reason you are probably better off having the site re-developed as finding all the global variables in your code and converting them could be a nightmare.

Link to comment
Share on other sites

Everyone.  Thanks for the help and advise.  This site is hosted somewhere else and I would not be surprised if they updated without telling us.  Now I will go break the news to my boss that we need to seriously look into bringing someone in to redesign this turd.

 

Thanks again!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.