Reply
Transferred Host, Can't get database info
Old 03-25-2008, 02:28 PM Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
I am trying to help my dad's friend move his site to a new host

I moved all the files over to godaddy. Everything is working...except for pulling info from the mysql database. I did import the database to the new host (godaddy). I show it is there and in phpmyadmin, I can see the database and its contents. It is all there.

The problem is, I have a file that is pulling up an error. Everything is EXACTLY the same as it was on the old server EXCEPT, I changed the database hostname, database name, username, and password. I get this result: http://www.cushionglide.com/list.php?key=1

I have no idea what is wrong. Why would it not work on the new server? Could it be a php or mysql version number??

Here are my files:

list.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
    <title>Cushion Glide</title>
    <link rel="stylesheet" type="text/css"
          href="layout.css" />
</head>

<body>
  <div id="outer">

        <div id="hdr" align="center">
          <div id="topMenu">
              <?php include ("topMenu2.php") ?>
          </div>
        </div>

  <div id="bodyblock" align="right">

        <div id="l-col" align="center">
                 <div id="productsTop"></div>
                 <div id="productsMiddle"><?php include ("productMenu2.php") ?></div>
                 <div id="productsBottom"></div>
        </div>

        <div id="cont">
<?php session_start(); ?>
<?php /* no security */ ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("functions.php") ?>
<?php
$displayRecs = 20;
$recRange = 10;

// Get table name
$tablename = "`stock`";
$dbwhere = "";
$a_search = "";
$b_search = "";
$key = @$HTTP_GET_VARS[key];
if(isset($HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$dbwhere = "Category = '$HTTP_GET_VARS[key]'";

if(strlen($sub) > 0)
{
    $dbwhere .= " and Class like '%$sub%'";
        }
}
?>
<?php
// Get search criteria for basic search
$pSearch = @$HTTP_GET_VARS["psearch"];
if ($pSearch != "")
{
        $pSearch = (!get_magic_quotes_gpc()) ? addslashes($pSearch) : $pSearch;
        $b_search .= "`ID` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Product_name` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Product_descr` LIKE '%".$pSearch."%' OR ";

        $b_search .= "`Class` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Model` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Details` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Location` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Wd` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`RegularHduty` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`TimbrenSES` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Package` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`AEON` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Braket` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`MdHdPrice` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`PriorTo` LIKE '%".$pSearch."%' OR ";
}
if (strlen($b_search) > 4)
{
        $b_search = substr($b_search, 0, strlen($b_search)-4);
        $b_search = "(".$b_search.")";
}
?>
<?php
//Build search criteria
if ($a_search != "")
{
        $dbwhere .= $a_search; //advance search
} elseif ($b_search!="") {
        $dbwhere .= $b_search; //basic search
}

//Save search criteria
if ($dbwhere != "")
{
           $HTTP_SESSION_VARS["tablename"] = $tablename;
    $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
        //reset start record counter
    $startRec = 1;
    $HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
    if ($tablename == @$HTTP_SESSION_VARS["tablename"])
    {
                $dbwhere = $HTTP_SESSION_VARS["dbwhere"];
    } else {
                //reset search criteria
              $dbwhere = "";
              $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
    }
}

//Get clear search cmd
$cmd = @$HTTP_GET_VARS["cmd"];
if (strtoupper($cmd)=="RESET")
{
        //reset search criteria
         $dbwhere = "";
         $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
?>
<?php
// Load Default Order
$DefaultOrder = "";
$DefaultOrderType = "";

// Check for an Order parameter
$OrderBy = @$HTTP_GET_VARS["order"];

if ($OrderBy != "")
{
        // Check if an ASC/DESC toggle is required
        if ($HTTP_SESSION_VARS["stock_OB"] == $OrderBy)
        {
                if ($HTTP_SESSION_VARS["stock_OT"] == "ASC")
                {
                        $HTTP_SESSION_VARS["stock_OT"] = "DESC";
                } else {
                        $HTTP_SESSION_VARS["stock_OT"] = "ASC";
                }
        } else {
                $HTTP_SESSION_VARS["stock_OT"] = "ASC";
        }
        $HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
        $HTTP_SESSION_VARS["stock_REC"] = 1;
} else {
        $OrderBy = @$HTTP_SESSION_VARS["stock_OB"];
        if ($OrderBy == "")
        {
                $OrderBy = $DefaultOrder;
                $HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
                $HTTP_SESSION_VARS["stock_OT"] = $DefaultOrderType;
        }
}

// Check for a START parameter
$startRec = @$HTTP_GET_VARS["start"];

if ($startRec != "")
{
        $HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
        $startRec = @$HTTP_SESSION_VARS["stock_REC"];
        if ($startRec == "")
        {
                //reset start record counter
                  $startRec = 1;
                  $HTTP_SESSION_VARS["stock_REC"] = $startRec;
        }
}

//Set the last record to display
$stopRec = $startRec + $displayRecs - 1;

// Open Connection to the database
$conn = mysql_connect(HOST, USER, PASS);
mysql_select_db(DB);

// Build Query
$strsql = "SELECT * FROM `Stock`";

if ($dbwhere != "")
{
        $strsql .= " WHERE ".$dbwhere;
}

if ($OrderBy != "")
{
        $strsql .= " ORDER BY Category, Model".@$HTTP_SESSION_VARS["stock_OT"];
}

$rs = mysql_query($strsql, $conn) or die(mysql_error());

$totalRecs = mysql_num_rows($rs);
?>

<?php

if(isset($HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$sub_title = "";
if(0 < strlen($sub))
{
    list($car_type, $car_num) = split(":", $sub);
    $sub_title = ($subcateg[$car_type][$car_num]);
        }

echo"<center>";
if(strlen($sub) < 1 and 4 !=$key and 5 != $key and 6 != $key and 7 != $key)
{
echo"| <a href=\"list.php?key=$key&sub=pickup\" class=\"navigation\">Pickups</a> | <a href=\"list.php?key=$key&sub=suv\" class=\"navigation\">SUV's</a> | <a href=\"list.php?key=$key&sub=van\" class=\"navigation\">Vans</a>|";
}

echo"</center><br>";
echo"<b>$categories[$key]$categ_ext</b><br><br>";

}
if(strlen($psearch) > 0){
echo"Search results (<b>$psearch</b>):<br><br>";
}

if(strlen($sub) > 0 or '4' == $key  or '5' == $key or '6' == $key or '7' == $key or strlen($psearch) > 0)
{
if('7' == $key)
{    // Jacks

$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
        $recCount++;
        if (intval($recCount) >= intval($startRec))
    {
                //set row color
                $bgcolor="#FFFFFF";
?>
<?php
                // Display alternate color for rows
                if ($recCount % 2 != 0)
                {
                        $bgcolor = "#F5F5F5";
                }
?>
<?php
$x_ID = $row["ID"];
$x_Product_name = $row["Product_name"];
$x_Product_descr = $row["Product_descr"];
$x_Quantity = $row["Quantity"];
$x_Price = $row["Price"];
$x_Category = $row["Category"];
$x_Status = $row["Status"];
$x_Product_descr = substr($x_Product_descr, 0, 15);

$x_CarType = $row["CarType"];
$x_Model = $row["Model"];
$x_Details = $row["Details"];
$x_DateFrom = $row["DateFrom"];
$x_DateTo = $row["DateTo"];
$x_Location = $row["Location"];
$x_Wd = $row["Wd"];
$x_RegularHduty = $row["RegularHduty"];
$x_TimbrenSES = $row["TimbrenSES"];
$x_Weight = $row["Weight"];
$x_Package = $row["Package"];
$x_UM = $row["UM"];
$x_AEON = $row["AEON"];
$x_Braket = $row["Braket"];
$x_Capacity = $row["Capacity"];
$x_LowPrice = $row["LowPrice"];
$x_MdHdPrice = $row["MdHdPrice"];
$x_PriorTo = $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front = $wd4_front = $wd2_rear = $wd4_rear = "";

 if($x_Price < 1)
{
        $price_pr = $price[$x_Price];
        }
        else
        {
                $price_pr = $x_Price;
                }

$item_notes="";
if($x_Status == "Out of stock"){
$item_notes = "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
echo"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> ($x_Model) \$$price_pr</b> $item_notes ...<br><br>";
/*
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
";
*/
        }
}

mysql_free_result($rs);
mysql_close($conn);

        }
        else{
    ?>

<br>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="145" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Model</b></font></td>
    <td width="128" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Year</b></font></td>
    <td width="170" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>2 Wheel
    Drive</b></font></td>
    <td width="141" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>4 Wheel
    Drive</b></font></td>
  </tr>
  <tr>
    <td width="86" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="81" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
    <td width="73" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="64" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
  </tr>
<?php

$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
        $recCount++;
        if (intval($recCount) >= intval($startRec))
    {
                //set row color
                $bgcolor="#FFFFFF";
?>
<?php
                // Display alternate color for rows
                if ($recCount % 2 != 0)
                {
                        $bgcolor = "#F5F5F5";
                }
?>
<?php
$x_ID = $row["ID"];
$x_Product_name = $row["Product_name"];
$x_Product_descr = $row["Product_descr"];
$x_Quantity = $row["Quantity"];
$x_Price = $row["Price"];
$x_Category = $row["Category"];
$x_Status = $row["Status"];
$x_Product_descr = substr($x_Product_descr, 0, 15);

$x_CarType = $row["CarType"];
$x_Model = $row["Model"];
$x_Details = $row["Details"];
$x_DateFrom = $row["DateFrom"];
$x_DateTo = $row["DateTo"];
$x_Location = $row["Location"];
$x_Wd = $row["Wd"];
$x_RegularHduty = $row["RegularHduty"];
$x_TimbrenSES = $row["TimbrenSES"];
$x_Weight = $row["Weight"];
$x_Package = $row["Package"];
$x_UM = $row["UM"];
$x_AEON = $row["AEON"];
$x_Braket = $row["Braket"];
$x_Capacity = $row["Capacity"];
$x_LowPrice = $row["LowPrice"];
$x_MdHdPrice = $row["MdHdPrice"];
$x_PriorTo = $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front = $wd4_front = $wd2_rear = $wd4_rear = "";
if (2 == $x_Wd_int and 'Front' == $x_Location)
{
    $wd2_front = "<a href=\"view.php?id=$x_ID\">Kit</a>";
        }
        else if(4 == $x_Wd_int and 'Front' == $x_Location)
        {
        $wd4_front = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                }
                else if(2 == $x_Wd_int and 'Rear' == $x_Location)
                {
            $wd2_rear = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                        }
                        else
                        {
                $wd4_rear = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                                }


$item_notes="";
if($x_Status == "Out of stock"){
$item_notes = "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
//echo"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> (\$$price[$x_Price])</b> $item_notes $x_Product_descr ...<br><br>";
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
";
        }
}

mysql_free_result($rs);
mysql_close($conn);
?>
</table>
<?php
}
if ($totalRecs > 0)
{
        // Find out if there should be Backward or Forward Buttons on the table.
        if ($startRec == 1)
        {
                 $isPrev = false;
        } else        {
                $isPrev = true;
                $PrevStart = $startRec - $displayRecs;
                if ($PrevStart < 1)
                {
                        $PrevStart = 1;
                }
?>
        <hr size="1" noshade>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $PrevStart; ?>"><font size="-1">[&lt;&lt;&nbsp;Prev]</font></a></strong>
<?php
        }

        // Display Page numbers
    if ($isPrev||(!($totalRecs == 0)))
    {
              if (!$isPrev)
              {
?>
        <hr size="1" noshade>
<?php
                }

                $x = 1;
              $y = 1;

              $dx1 = intval(($startRec - 1)/($displayRecs*$recRange))*$displayRecs*$recRange + 1;
             $dy1 = intval(($startRec - 1)/($displayRecs*$recRange))*$recRange + 1;
              if (($dx1 + $displayRecs*$recRange - 1) > $totalRecs)
                {
                        $dx2 = intval($totalRecs/$displayRecs)*$displayRecs + 1;
                        $dy2 = intval($totalRecs/$displayRecs) + 1;
                } else {
                        $dx2 = $dx1 + $displayRecs*$recRange - 1;
                          $dy2 = $dy1 + $recRange - 1;
                }


                while ($x <= $totalRecs)
              {
                        if (($x >= $dx1)&&($x <= $dx2))
                {
                          if (intval($startRec) == intval($x))
                          {
?>
        <strong><font size="-1"><?php echo $y; ?></font></strong>
<?php
                                } else {
?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
<?php
                                }
                         $x = $x + $displayRecs;
                          $y = $y + 1;
                } elseif (($x >= ($dx1 - $displayRecs*$recRange))&&($x <= ($dx2 + $displayRecs*$recRange)))
                {

                          if ($x + $recRange*$displayRecs < $totalRecs)
                          {
?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $y + $recRange - 1; ?></font></a></strong>
<?php
                                } else {
                            $ny = intval(($totalRecs - 1)/$displayRecs) + 1;
                                        if ($ny == $y)
                            {
        ?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
        <?php
                                        } else {
        ?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $ny; ?></font></a></strong>
        <?php
                                        }
                                }
                          $x = $x + $recRange*$displayRecs;
                          $y = $y + $recRange;
                } else {
                          $x = $x + $recRange*$displayRecs;
                          $y = $y + $recRange;
                }
                }
        }

        // Next link
    if ($totalRecs >= $startRec + $displayRecs)
    {
                $NextStart = $startRec + $displayRecs;
                $isMore = true;
 ?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $NextStart; ?>"><font size="-1">[Next&nbsp;&gt;&gt;]</font></a></strong>
<?php
        } else {
                $isMore=false;
    }
 ?>
        <hr size="1" noshade>
<?php
        if ($stopRec > $recCount)
    {
    $stopRec = $recCount;
        }
 ?>
        <font size="-1">Records <?php echo $startRec; ?> to <?php echo $stopRec; ?> of <?php echo $totalRecs; ?></font>
<?php
} else {
?>
<br><br>
<font size="-1">No records found!</font>
<br><br>
<?php
}
}

?>
         </div>

<br style="clear: both;" />

</div>
</div>

</body>
</html>

Functions.php (this sets the variables to connect to the database. I set the sensitive info to "removed" here just for security reasons
Code:
<?php
define("HOST", "removed");
define("USER", "removed");
define("PASS", "removed");
define("DB", "removed");

$home_url = "http://www.cushionglide.com";
$path2upload ="pictures";

$categories[1] = 'Ford';
$categories[2] = 'Chevy';
$categories[3] = 'Dodge';
$categories[4] = 'Nissan';
$categories[5] = 'Toyota';
$categories[6] = 'Trailers';
$categories[7] = 'Jacks';

$subcateg[pickup][0] = 'Pickups - 2wd';
$subcateg[pickup][1] = 'Pickups - 4wd';
$subcateg[pickup][2] = 'Avalanche';

$subcateg[name][pickup] = 'Pickups';

$subcateg[suv][0] = 'Avalanche';
$subcateg[suv][1] = 'Blazer / Jimmy';
$subcateg[suv][2] = 'Escalade / Denali';
$subcateg[suv][3] = 'Suburban';
$subcateg[suv][4] = 'Tahoe / Yukon';
$subcateg[suv][5] = 'Trailblazer / Envoy / Bravada';

$subcateg[name][suv] = 'SUV\'s';

//Ford
$subcateg[suv][6] = 'Bronco';
$subcateg[suv][7] = 'Explorer';
$subcateg[suv][8] = 'Excursion';
$subcateg[suv][9] = 'Expedition';

//Chevy
$subcateg[suv][10] = 'Suburban / Yukon';
$subcateg[suv][11] = 'Tahoe';
$subcateg[suv][12] = 'Blazer/Jimmy';
$subcateg[suv][13] = 'Escalade / Denali';

//Dodge
$subcateg[suv][14] = 'Durango';


//Chevy
$subcateg[van][0] = 'G - Series';
$subcateg[van][1] = 'Astro, Safari, Bravado';
$subcateg[van][2] = 'Lumina APV, Venture';
$subcateg[van][3] = 'Silouette';
$subcateg[van][4] = 'Transport';

//Ford
$subcateg[van][5] = 'Aerostar';
$subcateg[van][6] = 'Villager';
$subcateg[van][7] = 'Windstar';
$subcateg[van][8] = 'E-Series Vans';

//Dodge
$subcateg[van][9] = 'Caravan, Voyager';
$subcateg[van][10] = 'Town & Country';
$subcateg[van][11] = 'B-Series Vans';
$subcateg[van][12] = 'PT-Cruiser';

$subcateg[name][van] = 'Vans';

//Ford
$subs_by_make[1][pickup][0] = true;
$subs_by_make[1][pickup][1] = true;

$subs_by_make[1][suv][6] = true;
$subs_by_make[1][suv][7] = true;
$subs_by_make[1][suv][8] = true;
$subs_by_make[1][suv][9] = true;

$subs_by_make[1][van][5] = true;
$subs_by_make[1][van][6] = true;
$subs_by_make[1][van][7] = true;
$subs_by_make[1][van][8] = true;

//Chevy
$subs_by_make[2][pickup][0] = true;
$subs_by_make[2][pickup][1] = true;

$subs_by_make[2][suv][10] = true;
$subs_by_make[2][suv][11] = true;
$subs_by_make[2][suv][12] = true;
$subs_by_make[2][suv][13] = true;

$subs_by_make[2][van][0] = true;
$subs_by_make[2][van][1] = true;
$subs_by_make[2][van][2] = true;
$subs_by_make[2][van][3] = true;
$subs_by_make[2][van][4] = true;

//Dodge
$subs_by_make[3][pickup][0] = true;
$subs_by_make[3][pickup][1] = true;

$subs_by_make[3][suv][14] = true;

$subs_by_make[3][van][9] = true;
$subs_by_make[3][van][10] = true;
$subs_by_make[3][van][11] = true;
$subs_by_make[3][van][12] = true;


//Prices
$price[A] = 169.95;
$price[B] = 199.95;
$price[C] = 333.79;
$price[D] = 363.95;
$price[F] = 426.08;
$price[H] = 478.4;
$price[I] = 526.24;
$price[J] = 672.76;
$price[L] = 799.82;
$price[M] = 852.16;
$price[N] = 1024.4;

//---------------------------------------------------------------------------------------------------------
// Convert a date to MySQL format
function ConvertDateToMysqlFormat($dateStr)
{
    switch (DEFAULT_DATE_FORMAT) {
    case "yyyy/mm/dd":
        list ($year, $month, $day) = split("/", $dateStr);
        break;
    case "mm/dd/yyyy":
        list ($month, $day, $year) = split("/", $dateStr);
        break;
    case "dd/mm/yyyy":
        list ($day, $month, $year) = split("/", $dateStr);
        break;
        }
        if(4 == strlen($dateStr))
        {
                return  "$dateStr";
                }
    return $year . "-" . $month . "-" . $day;
}
?>
Thanks!!
__________________
Webmaster-Talk Rules

Last edited by angele803; 03-29-2008 at 08:49 AM..
angele803 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 03-25-2008, 04:02 PM Re: Transferred Host, Can't get database info
rogem002's Avatar
Super Spam Talker

Latest Blog Post:
Making Zebra Stripes with CSS3
Posts: 837
Name: Mike
Location: United Kingdom
Trades: 0
Change the code on "list.php" to:

PHP Code:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
    <title>Cushion Glide</title>
    <link rel="stylesheet" type="text/css"
          href="layout.css" />
</head>

<body>
  <div id="outer">

        <div id="hdr" align="center">
          <div id="topMenu">
              <?php include ("topMenu2.php"?>
          </div>
        </div>

  <div id="bodyblock" align="right">

        <div id="l-col" align="center">
                 <div id="productsTop"></div>
                 <div id="productsMiddle"><?php include ("productMenu2.php"?></div>
                 <div id="productsBottom"></div>
        </div>

        <div id="cont">
<?php /* no security */ ?>
<?php
header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0"false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php 
include ("functions.php"?>
<?php
$displayRecs 
20;
$recRange 10;

// Get table name
$tablename "`stock`";
$dbwhere "";
$a_search "";
$b_search "";
$key = @$HTTP_GET_VARS[key];
if(isset(
$HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$dbwhere "Category = '$HTTP_GET_VARS[key]'";

if(
strlen($sub) > 0)
{
    
$dbwhere .= " and Class like '%$sub%'";
        }
}
?>
<?php
// Get search criteria for basic search
$pSearch = @$HTTP_GET_VARS["psearch"];
if (
$pSearch != "")
{
        
$pSearch = (!get_magic_quotes_gpc()) ? addslashes($pSearch) : $pSearch;
        
$b_search .= "`ID` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Product_name` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Product_descr` LIKE '%".$pSearch."%' OR ";

        
$b_search .= "`Class` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Model` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Details` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Location` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Wd` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`RegularHduty` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`TimbrenSES` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Package` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`AEON` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`Braket` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`MdHdPrice` LIKE '%".$pSearch."%' OR ";
        
$b_search .= "`PriorTo` LIKE '%".$pSearch."%' OR ";
}
if (
strlen($b_search) > 4)
{
        
$b_search substr($b_search0strlen($b_search)-4);
        
$b_search "(".$b_search.")";
}
?>
<?php
//Build search criteria
if ($a_search != "")
{
        
$dbwhere .= $a_search//advance search
} elseif ($b_search!="") {
        
$dbwhere .= $b_search//basic search
}

//Save search criteria
if ($dbwhere != "")
{
           
$HTTP_SESSION_VARS["tablename"] = $tablename;
    
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
        
//reset start record counter
    
$startRec 1;
    
$HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
    if (
$tablename == @$HTTP_SESSION_VARS["tablename"])
    {
                
$dbwhere $HTTP_SESSION_VARS["dbwhere"];
    } else {
                
//reset search criteria
              
$dbwhere "";
              
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
    }
}

//Get clear search cmd
$cmd = @$HTTP_GET_VARS["cmd"];
if (
strtoupper($cmd)=="RESET")
{
        
//reset search criteria
         
$dbwhere "";
         
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
?>
<?php
// Load Default Order
$DefaultOrder "";
$DefaultOrderType "";

// Check for an Order parameter
$OrderBy = @$HTTP_GET_VARS["order"];

if (
$OrderBy != "")
{
        
// Check if an ASC/DESC toggle is required
        
if ($HTTP_SESSION_VARS["stock_OB"] == $OrderBy)
        {
                if (
$HTTP_SESSION_VARS["stock_OT"] == "ASC")
                {
                        
$HTTP_SESSION_VARS["stock_OT"] = "DESC";
                } else {
                        
$HTTP_SESSION_VARS["stock_OT"] = "ASC";
                }
        } else {
                
$HTTP_SESSION_VARS["stock_OT"] = "ASC";
        }
        
$HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
        
$HTTP_SESSION_VARS["stock_REC"] = 1;
} else {
        
$OrderBy = @$HTTP_SESSION_VARS["stock_OB"];
        if (
$OrderBy == "")
        {
                
$OrderBy $DefaultOrder;
                
$HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
                
$HTTP_SESSION_VARS["stock_OT"] = $DefaultOrderType;
        }
}

// Check for a START parameter
$startRec = @$HTTP_GET_VARS["start"];

if (
$startRec != "")
{
        
$HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
        
$startRec = @$HTTP_SESSION_VARS["stock_REC"];
        if (
$startRec == "")
        {
                
//reset start record counter
                  
$startRec 1;
                  
$HTTP_SESSION_VARS["stock_REC"] = $startRec;
        }
}

//Set the last record to display
$stopRec $startRec $displayRecs 1;

// Open Connection to the database
$conn mysql_connect(HOSTUSERPASS);
mysql_select_db(DB);

// Build Query
$strsql "SELECT * FROM `Stock`";

if (
$dbwhere != "")
{
        
$strsql .= " WHERE ".$dbwhere;
}

if (
$OrderBy != "")
{
        
$strsql .= " ORDER BY Category, Model".@$HTTP_SESSION_VARS["stock_OT"];
}

$rs mysql_query($strsql$conn) or die(mysql_error());

$totalRecs mysql_num_rows($rs);
?>

<?php

if(isset($HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$sub_title "";
if(
strlen($sub))
{
    list(
$car_type$car_num) = split(":"$sub);
    
$sub_title = ($subcateg[$car_type][$car_num]);
        }

echo
"<center>";
if(
strlen($sub) < and !=$key and != $key and != $key and != $key)
{
echo
"| <a href=\"list.php?key=$key&sub=pickup\" class=\"navigation\">Pickups</a> | <a href=\"list.php?key=$key&sub=suv\" class=\"navigation\">SUV's</a> | <a href=\"list.php?key=$key&sub=van\" class=\"navigation\">Vans</a>|";
}

echo
"</center><br>";
echo
"<b>$categories[$key]$categ_ext</b><br><br>";

}
if(
strlen($psearch) > 0){
echo
"Search results (<b>$psearch</b>):<br><br>";
}

if(
strlen($sub) > or '4' == $key  or '5' == $key or '6' == $key or '7' == $key or strlen($psearch) > 0)
{
if(
'7' == $key)
{    
// Jacks

$recCount $startRec 1;
@
mysql_data_seek($rs$recCount);
while ((
$row mysql_fetch_assoc($rs)) && ($recCount $stopRec))
{
        
$recCount++;
        if (
intval($recCount) >= intval($startRec))
    {
                
//set row color
                
$bgcolor="#FFFFFF";
?>
<?php
                
// Display alternate color for rows
                
if ($recCount != 0)
                {
                        
$bgcolor "#F5F5F5";
                }
?>
<?php
$x_ID 
$row["ID"];
$x_Product_name $row["Product_name"];
$x_Product_descr $row["Product_descr"];
$x_Quantity $row["Quantity"];
$x_Price $row["Price"];
$x_Category $row["Category"];
$x_Status $row["Status"];
$x_Product_descr substr($x_Product_descr015);

$x_CarType $row["CarType"];
$x_Model $row["Model"];
$x_Details $row["Details"];
$x_DateFrom $row["DateFrom"];
$x_DateTo $row["DateTo"];
$x_Location $row["Location"];
$x_Wd $row["Wd"];
$x_RegularHduty $row["RegularHduty"];
$x_TimbrenSES $row["TimbrenSES"];
$x_Weight $row["Weight"];
$x_Package $row["Package"];
$x_UM $row["UM"];
$x_AEON $row["AEON"];
$x_Braket $row["Braket"];
$x_Capacity $row["Capacity"];
$x_LowPrice $row["LowPrice"];
$x_MdHdPrice $row["MdHdPrice"];
$x_PriorTo $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front $wd4_front $wd2_rear $wd4_rear "";

 if(
$x_Price 1)
{
        
$price_pr $price[$x_Price];
        }
        else
        {
                
$price_pr $x_Price;
                }

$item_notes="";
if(
$x_Status == "Out of stock"){
$item_notes "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
echo
"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> ($x_Model) \$$price_pr</b> $item_notes ...<br><br>";
/*
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
";
*/
        
}
}

mysql_free_result($rs);
mysql_close($conn);

        }
        else{
    
?>

<br>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="145" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Model</b></font></td>
    <td width="128" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Year</b></font></td>
    <td width="170" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>2 Wheel
    Drive</b></font></td>
    <td width="141" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>4 Wheel
    Drive</b></font></td>
  </tr>
  <tr>
    <td width="86" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="81" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
    <td width="73" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="64" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
  </tr>
<?php

$recCount 
$startRec 1;
@
mysql_data_seek($rs$recCount);
while ((
$row mysql_fetch_assoc($rs)) && ($recCount $stopRec))
{
        
$recCount++;
        if (
intval($recCount) >= intval($startRec))
    {
                
//set row color
                
$bgcolor="#FFFFFF";
?>
<?php
                
// Display alternate color for rows
                
if ($recCount != 0)
                {
                        
$bgcolor "#F5F5F5";
                }
?>
<?php
$x_ID 
$row["ID"];
$x_Product_name $row["Product_name"];
$x_Product_descr $row["Product_descr"];
$x_Quantity $row["Quantity"];
$x_Price $row["Price"];
$x_Category $row["Category"];
$x_Status $row["Status"];
$x_Product_descr substr($x_Product_descr015);

$x_CarType $row["CarType"];
$x_Model $row["Model"];
$x_Details $row["Details"];
$x_DateFrom $row["DateFrom"];
$x_DateTo $row["DateTo"];
$x_Location $row["Location"];
$x_Wd $row["Wd"];
$x_RegularHduty $row["RegularHduty"];
$x_TimbrenSES $row["TimbrenSES"];
$x_Weight $row["Weight"];
$x_Package $row["Package"];
$x_UM $row["UM"];
$x_AEON $row["AEON"];
$x_Braket $row["Braket"];
$x_Capacity $row["Capacity"];
$x_LowPrice $row["LowPrice"];
$x_MdHdPrice $row["MdHdPrice"];
$x_PriorTo $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front $wd4_front $wd2_rear $wd4_rear "";
if (
== $x_Wd_int and 'Front' == $x_Location)
{
    
$wd2_front "<a href=\"view.php?id=$x_ID\">Kit</a>";
        }
        else if(
== $x_Wd_int and 'Front' == $x_Location)
        {
        
$wd4_front "<a href=\"view.php?id=$x_ID\">Kit</a>";
                }
                else if(
== $x_Wd_int and 'Rear' == $x_Location)
                {
            
$wd2_rear "<a href=\"view.php?id=$x_ID\">Kit</a>";
                        }
                        else
                        {
                
$wd4_rear "<a href=\"view.php?id=$x_ID\">Kit</a>";
                                }


$item_notes="";
if(
$x_Status == "Out of stock"){
$item_notes "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
//echo"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> (\$$price[$x_Price])</b> $item_notes $x_Product_descr ...<br><br>";
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
"
;
        }
}

mysql_free_result($rs);
mysql_close($conn);
?>
</table>
<?php
}
if (
$totalRecs 0)
{
        
// Find out if there should be Backward or Forward Buttons on the table.
        
if ($startRec == 1)
        {
                 
$isPrev false;
        } else        {
                
$isPrev true;
                
$PrevStart $startRec $displayRecs;
                if (
$PrevStart 1)
                {
                        
$PrevStart 1;
                }
?>
        <hr size="1" noshade>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $PrevStart?>"><font size="-1">[&lt;&lt;&nbsp;Prev]</font></a></strong>
<?php
        
}

        
// Display Page numbers
    
if ($isPrev||(!($totalRecs == 0)))
    {
              if (!
$isPrev)
              {
?>
        <hr size="1" noshade>
<?php
                
}

                
$x 1;
              
$y 1;

              
$dx1 intval(($startRec 1)/($displayRecs*$recRange))*$displayRecs*$recRange 1;
             
$dy1 intval(($startRec 1)/($displayRecs*$recRange))*$recRange 1;
              if ((
$dx1 $displayRecs*$recRange 1) > $totalRecs)
                {
                        
$dx2 intval($totalRecs/$displayRecs)*$displayRecs 1;
                        
$dy2 intval($totalRecs/$displayRecs) + 1;
                } else {
                        
$dx2 $dx1 $displayRecs*$recRange 1;
                          
$dy2 $dy1 $recRange 1;
                }


                while (
$x <= $totalRecs)
              {
                        if ((
$x >= $dx1)&&($x <= $dx2))
                {
                          if (
intval($startRec) == intval($x))
                          {
?>
        <strong><font size="-1"><?php echo $y?></font></strong>
<?php
                                
} else {
?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x?>"><font size="-1"><?php echo $y?></font></a></strong>
<?php
                                
}
                         
$x $x $displayRecs;
                          
$y $y 1;
                } elseif ((
$x >= ($dx1 $displayRecs*$recRange))&&($x <= ($dx2 $displayRecs*$recRange)))
                {

                          if (
$x $recRange*$displayRecs $totalRecs)
                          {
?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x?>"><font size="-1"><?php echo $y?>-<?php echo $y $recRange 1?></font></a></strong>
<?php
                                
} else {
                            
$ny intval(($totalRecs 1)/$displayRecs) + 1;
                                        if (
$ny == $y)
                            {
        
?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x?>"><font size="-1"><?php echo $y?></font></a></strong>
        <?php
                                        
} else {
        
?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x?>"><font size="-1"><?php echo $y?>-<?php echo $ny?></font></a></strong>
        <?php
                                        
}
                                }
                          
$x $x $recRange*$displayRecs;
                          
$y $y $recRange;
                } else {
                          
$x $x $recRange*$displayRecs;
                          
$y $y $recRange;
                }
                }
        }

        
// Next link
    
if ($totalRecs >= $startRec $displayRecs)
    {
                
$NextStart $startRec $displayRecs;
                
$isMore true;
 
?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $NextStart?>"><font size="-1">[Next&nbsp;&gt;&gt;]</font></a></strong>
<?php
        
} else {
                
$isMore=false;
    }
 
?>
        <hr size="1" noshade>
<?php
        
if ($stopRec $recCount)
    {
    
$stopRec $recCount;
        }
 
?>
        <font size="-1">Records <?php echo $startRec?> to <?php echo $stopRec?> of <?php echo $totalRecs?></font>
<?php
} else {
?>
<br><br>
<font size="-1">No records found!</font>
<br><br>
<?php
}
}

?>
         </div>

<br style="clear: both;" />

</div>
</div>

</body>
</html>
It looked to me like the session_start() was after some html was sent...most likely a change in settings from host to host.
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
Fix 90% of your problems | Full On Design

Last edited by rogem002; 03-25-2008 at 04:04 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 03-25-2008, 04:04 PM Re: Transferred Host, Can't get database info
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
Mike is correct. session_start should always be the first line of the file.
joder is offline
Reply With Quote
View Public Profile
 
Old 03-25-2008, 04:08 PM Re: Transferred Host, Can't get database info
tripy's Avatar
Do not try this at home!

Posts: 3,139
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Stephanie,
surely a configuration change between the 2 hosts.

What you can do to (try) to correct it, is to add in a .htaccess file in your site root folder this line:
Code:
php_flag session.auto_start on
Sometime, it must be wrote php_admin_flag, so if the first don't work, try the second.

As the session uses a cookie to get registered, the script must not send any html content before doing a session start. That's the reason of your error.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-25-2008, 06:42 PM Re: Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
Thanks guys. I got the errors to go away.
Now the problem is that no results are showing up. It is like the php code is not parsing or something. I had an .htaccess file on the old host. I transferred it before moving servers, but I did something wrong, because when I opened it just now, it was blank. So I tried a couple of things with the htaccess file (like what tripy said to try) and nothing changed. So I deleted it, and still nothing changed. Why wouldn't the php spit out any information? I picked php version 5 for the new server. If this old code was written (I didn't write it) for php 4, could that be the cause???
__________________
Webmaster-Talk Rules
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-26-2008, 12:38 PM Re: Transferred Host, Can't get database info
rogem002's Avatar
Super Spam Talker

Latest Blog Post:
Making Zebra Stripes with CSS3
Posts: 837
Name: Mike
Location: United Kingdom
Trades: 0
Just a quick heads up that your host seems to be not proceesing the page as PHP and thus showing the code. Take a look at your .httaccess file.
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
Fix 90% of your problems | Full On Design

Last edited by rogem002; 03-26-2008 at 12:41 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 03-26-2008, 03:48 PM Re: Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
I was messing with the .htaccess file and made the code show up by accident. It is fixed now.

If you look at it now, you can see my problem. There should be an html table with data in it....but nothing is there...
__________________
Webmaster-Talk Rules
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-26-2008, 03:51 PM Re: Transferred Host, Can't get database info
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
Can you post any relevant PHP code and database structure?
joder is offline
Reply With Quote
View Public Profile
 
Old 03-26-2008, 04:12 PM Re: Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
Sure - not much has changed from the code in my first post. The functions.php is exactly the same as in my first post. The only thing that changed in my list.php file is that I moved the session_start and headers to the top. Here is how it looks now:

list.php
Code:
<?php session_start(); ?>
<?php /* no security */ ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
    <title>Cushion Glide</title>
    <link rel="stylesheet" type="text/css"
          href="layout.css" />
</head>

<body>
  <div id="outer">

        <div id="hdr" align="center">
          <div id="topMenu">
              <?php include ("topMenu2.php") ?>
          </div>
        </div>

  <div id="bodyblock" align="right">

        <div id="l-col" align="center">
                 <div id="productsTop"></div>
                 <div id="productsMiddle"><?php include ("productMenu2.php") ?></div>
                 <div id="productsBottom"></div>
        </div>

        <div id="cont">

<?php include ("functions.php") ?>
<?php
$displayRecs = 20;
$recRange = 10;

// Get table name
$tablename = "`stock`";
$dbwhere = "";
$a_search = "";
$b_search = "";
$key = @$HTTP_GET_VARS[key];
if(isset($HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$dbwhere = "Category = '$HTTP_GET_VARS[key]'";

if(strlen($sub) > 0)
{
    $dbwhere .= " and Class like '%$sub%'";
        }
}
?>
<?php
// Get search criteria for basic search
$pSearch = @$HTTP_GET_VARS["psearch"];
if ($pSearch != "")
{
        $pSearch = (!get_magic_quotes_gpc()) ? addslashes($pSearch) : $pSearch;
        $b_search .= "`ID` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Product_name` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Product_descr` LIKE '%".$pSearch."%' OR ";

        $b_search .= "`Class` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Model` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Details` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Location` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Wd` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`RegularHduty` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`TimbrenSES` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Package` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`AEON` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`Braket` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`MdHdPrice` LIKE '%".$pSearch."%' OR ";
        $b_search .= "`PriorTo` LIKE '%".$pSearch."%' OR ";
}
if (strlen($b_search) > 4)
{
        $b_search = substr($b_search, 0, strlen($b_search)-4);
        $b_search = "(".$b_search.")";
}
?>
<?php
//Build search criteria
if ($a_search != "")
{
        $dbwhere .= $a_search; //advance search
} elseif ($b_search!="") {
        $dbwhere .= $b_search; //basic search
}

//Save search criteria
if ($dbwhere != "")
{
           $HTTP_SESSION_VARS["tablename"] = $tablename;
    $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
        //reset start record counter
    $startRec = 1;
    $HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
    if ($tablename == @$HTTP_SESSION_VARS["tablename"])
    {
                $dbwhere = $HTTP_SESSION_VARS["dbwhere"];
    } else {
                //reset search criteria
              $dbwhere = "";
              $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
    }
}

//Get clear search cmd
$cmd = @$HTTP_GET_VARS["cmd"];
if (strtoupper($cmd)=="RESET")
{
        //reset search criteria
         $dbwhere = "";
         $HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
?>
<?php
// Load Default Order
$DefaultOrder = "";
$DefaultOrderType = "";

// Check for an Order parameter
$OrderBy = @$HTTP_GET_VARS["order"];

if ($OrderBy != "")
{
        // Check if an ASC/DESC toggle is required
        if ($HTTP_SESSION_VARS["stock_OB"] == $OrderBy)
        {
                if ($HTTP_SESSION_VARS["stock_OT"] == "ASC")
                {
                        $HTTP_SESSION_VARS["stock_OT"] = "DESC";
                } else {
                        $HTTP_SESSION_VARS["stock_OT"] = "ASC";
                }
        } else {
                $HTTP_SESSION_VARS["stock_OT"] = "ASC";
        }
        $HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
        $HTTP_SESSION_VARS["stock_REC"] = 1;
} else {
        $OrderBy = @$HTTP_SESSION_VARS["stock_OB"];
        if ($OrderBy == "")
        {
                $OrderBy = $DefaultOrder;
                $HTTP_SESSION_VARS["stock_OB"] = $OrderBy;
                $HTTP_SESSION_VARS["stock_OT"] = $DefaultOrderType;
        }
}

// Check for a START parameter
$startRec = @$HTTP_GET_VARS["start"];

if ($startRec != "")
{
        $HTTP_SESSION_VARS["stock_REC"] = $startRec;
} else {
        $startRec = @$HTTP_SESSION_VARS["stock_REC"];
        if ($startRec == "")
        {
                //reset start record counter
                  $startRec = 1;
                  $HTTP_SESSION_VARS["stock_REC"] = $startRec;
        }
}

//Set the last record to display
$stopRec = $startRec + $displayRecs - 1;

// Open Connection to the database
$conn = mysql_connect(HOST, USER, PASS);
mysql_select_db(DB);

// Build Query
$strsql = "SELECT * FROM `Stock`";

if ($dbwhere != "")
{
        $strsql .= " WHERE ".$dbwhere;
}

if ($OrderBy != "")
{
        $strsql .= " ORDER BY Category, Model".@$HTTP_SESSION_VARS["stock_OT"];
}

$rs = mysql_query($strsql, $conn) or die(mysql_error());

$totalRecs = mysql_num_rows($rs);
?>

<?php

if(isset($HTTP_GET_VARS[key]) and strlen($HTTP_GET_VARS[key]) > 0){
$sub_title = "";
if(0 < strlen($sub))
{
    list($car_type, $car_num) = split(":", $sub);
    $sub_title = ($subcateg[$car_type][$car_num]);
        }

echo"<center>";
if(strlen($sub) < 1 and 4 !=$key and 5 != $key and 6 != $key and 7 != $key)
{
echo"| <a href=\"list.php?key=$key&sub=pickup\" class=\"navigation\">Pickups</a> | <a href=\"list.php?key=$key&sub=suv\" class=\"navigation\">SUV's</a> | <a href=\"list.php?key=$key&sub=van\" class=\"navigation\">Vans</a>|";
}

echo"</center><br>";
echo"<b>$categories[$key]$categ_ext</b><br><br>";

}
if(strlen($psearch) > 0){
echo"Search results (<b>$psearch</b>):<br><br>";
}

if(strlen($sub) > 0 or '4' == $key  or '5' == $key or '6' == $key or '7' == $key or strlen($psearch) > 0)
{
if('7' == $key)
{    // Jacks

$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
        $recCount++;
        if (intval($recCount) >= intval($startRec))
    {
                //set row color
                $bgcolor="#FFFFFF";
?>
<?php
                // Display alternate color for rows
                if ($recCount % 2 != 0)
                {
                        $bgcolor = "#F5F5F5";
                }
?>
<?php
$x_ID = $row["ID"];
$x_Product_name = $row["Product_name"];
$x_Product_descr = $row["Product_descr"];
$x_Quantity = $row["Quantity"];
$x_Price = $row["Price"];
$x_Category = $row["Category"];
$x_Status = $row["Status"];
$x_Product_descr = substr($x_Product_descr, 0, 15);

$x_CarType = $row["CarType"];
$x_Model = $row["Model"];
$x_Details = $row["Details"];
$x_DateFrom = $row["DateFrom"];
$x_DateTo = $row["DateTo"];
$x_Location = $row["Location"];
$x_Wd = $row["Wd"];
$x_RegularHduty = $row["RegularHduty"];
$x_TimbrenSES = $row["TimbrenSES"];
$x_Weight = $row["Weight"];
$x_Package = $row["Package"];
$x_UM = $row["UM"];
$x_AEON = $row["AEON"];
$x_Braket = $row["Braket"];
$x_Capacity = $row["Capacity"];
$x_LowPrice = $row["LowPrice"];
$x_MdHdPrice = $row["MdHdPrice"];
$x_PriorTo = $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front = $wd4_front = $wd2_rear = $wd4_rear = "";

 if($x_Price < 1)
{
        $price_pr = $price[$x_Price];
        }
        else
        {
                $price_pr = $x_Price;
                }

$item_notes="";
if($x_Status == "Out of stock"){
$item_notes = "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
echo"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> ($x_Model) \$$price_pr</b> $item_notes ...<br><br>";
/*
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
";
*/
        }
}

mysql_free_result($rs);
mysql_close($conn);

        }
        else{
    ?>

<br>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="145" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Model</b></font></td>
    <td width="128" rowspan="2" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Year</b></font></td>
    <td width="170" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>2 Wheel
    Drive</b></font></td>
    <td width="141" bgcolor="#5F72BA" colspan="2">
    <p align="center"><font color="#FFFFFF"><b>4 Wheel
    Drive</b></font></td>
  </tr>
  <tr>
    <td width="86" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="81" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
    <td width="73" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Front Kit</b></font></td>
    <td width="64" bgcolor="#5F72BA">
    <p align="center"><font color="#FFFFFF"><b>Rear Kit</b></font></td>
  </tr>
<?php

$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
        $recCount++;
        if (intval($recCount) >= intval($startRec))
    {
                //set row color
                $bgcolor="#FFFFFF";
?>
<?php
                // Display alternate color for rows
                if ($recCount % 2 != 0)
                {
                        $bgcolor = "#F5F5F5";
                }
?>
<?php
$x_ID = $row["ID"];
$x_Product_name = $row["Product_name"];
$x_Product_descr = $row["Product_descr"];
$x_Quantity = $row["Quantity"];
$x_Price = $row["Price"];
$x_Category = $row["Category"];
$x_Status = $row["Status"];
$x_Product_descr = substr($x_Product_descr, 0, 15);

$x_CarType = $row["CarType"];
$x_Model = $row["Model"];
$x_Details = $row["Details"];
$x_DateFrom = $row["DateFrom"];
$x_DateTo = $row["DateTo"];
$x_Location = $row["Location"];
$x_Wd = $row["Wd"];
$x_RegularHduty = $row["RegularHduty"];
$x_TimbrenSES = $row["TimbrenSES"];
$x_Weight = $row["Weight"];
$x_Package = $row["Package"];
$x_UM = $row["UM"];
$x_AEON = $row["AEON"];
$x_Braket = $row["Braket"];
$x_Capacity = $row["Capacity"];
$x_LowPrice = $row["LowPrice"];
$x_MdHdPrice = $row["MdHdPrice"];
$x_PriorTo = $row["PriorTo"];

$x_Wd_int = (int)$x_Wd;
$wd2_front = $wd4_front = $wd2_rear = $wd4_rear = "";
if (2 == $x_Wd_int and 'Front' == $x_Location)
{
    $wd2_front = "<a href=\"view.php?id=$x_ID\">Kit</a>";
        }
        else if(4 == $x_Wd_int and 'Front' == $x_Location)
        {
        $wd4_front = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                }
                else if(2 == $x_Wd_int and 'Rear' == $x_Location)
                {
            $wd2_rear = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                        }
                        else
                        {
                $wd4_rear = "<a href=\"view.php?id=$x_ID\">Kit</a>";
                                }


$item_notes="";
if($x_Status == "Out of stock"){
$item_notes = "<font color=\"#C0C0C0\">[Out of stock]</font>";
}
//echo"<b><a href=\"view.php?id=$x_ID\">$x_Product_name</a> (\$$price[$x_Price])</b> $item_notes $x_Product_descr ...<br><br>";
echo"
  <tr>
    <td width=\"145\">$x_Model</td>
    <td align=\"center\" width=\"128\">$x_DateFrom - $x_DateTo</td>
    <td align=\"center\" width=\"86\">$wd2_front</td>
    <td align=\"center\" width=\"81\">$wd2_rear</td>
    <td align=\"center\" width=\"73\">$wd4_front</td>
    <td align=\"center\" width=\"64\">$wd4_rear</td>
  </tr>
";
        }
}

mysql_free_result($rs);
mysql_close($conn);
?>
</table>
<?php
}
if ($totalRecs > 0)
{
        // Find out if there should be Backward or Forward Buttons on the table.
        if ($startRec == 1)
        {
                 $isPrev = false;
        } else        {
                $isPrev = true;
                $PrevStart = $startRec - $displayRecs;
                if ($PrevStart < 1)
                {
                        $PrevStart = 1;
                }
?>
        <hr size="1" noshade>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $PrevStart; ?>"><font size="-1">[&lt;&lt;&nbsp;Prev]</font></a></strong>
<?php
        }

        // Display Page numbers
    if ($isPrev||(!($totalRecs == 0)))
    {
              if (!$isPrev)
              {
?>
        <hr size="1" noshade>
<?php
                }

                $x = 1;
              $y = 1;

              $dx1 = intval(($startRec - 1)/($displayRecs*$recRange))*$displayRecs*$recRange + 1;
             $dy1 = intval(($startRec - 1)/($displayRecs*$recRange))*$recRange + 1;
              if (($dx1 + $displayRecs*$recRange - 1) > $totalRecs)
                {
                        $dx2 = intval($totalRecs/$displayRecs)*$displayRecs + 1;
                        $dy2 = intval($totalRecs/$displayRecs) + 1;
                } else {
                        $dx2 = $dx1 + $displayRecs*$recRange - 1;
                          $dy2 = $dy1 + $recRange - 1;
                }


                while ($x <= $totalRecs)
              {
                        if (($x >= $dx1)&&($x <= $dx2))
                {
                          if (intval($startRec) == intval($x))
                          {
?>
        <strong><font size="-1"><?php echo $y; ?></font></strong>
<?php
                                } else {
?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
<?php
                                }
                         $x = $x + $displayRecs;
                          $y = $y + 1;
                } elseif (($x >= ($dx1 - $displayRecs*$recRange))&&($x <= ($dx2 + $displayRecs*$recRange)))
                {

                          if ($x + $recRange*$displayRecs < $totalRecs)
                          {
?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $y + $recRange - 1; ?></font></a></strong>
<?php
                                } else {
                            $ny = intval(($totalRecs - 1)/$displayRecs) + 1;
                                        if ($ny == $y)
                            {
        ?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
        <?php
                                        } else {
        ?>
                <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $ny; ?></font></a></strong>
        <?php
                                        }
                                }
                          $x = $x + $recRange*$displayRecs;
                          $y = $y + $recRange;
                } else {
                          $x = $x + $recRange*$displayRecs;
                          $y = $y + $recRange;
                }
                }
        }

        // Next link
    if ($totalRecs >= $startRec + $displayRecs)
    {
                $NextStart = $startRec + $displayRecs;
                $isMore = true;
 ?>
        <strong><a href="list.php?sub=<?=$sub?>&key=<?=$key?>&psearch=<?=$psearch?>&start=<?php echo $NextStart; ?>"><font size="-1">[Next&nbsp;&gt;&gt;]</font></a></strong>
<?php
        } else {
                $isMore=false;
    }
 ?>
        <hr size="1" noshade>
<?php
        if ($stopRec > $recCount)
    {
    $stopRec = $recCount;
        }
 ?>
        <font size="-1">Records <?php echo $startRec; ?> to <?php echo $stopRec; ?> of <?php echo $totalRecs; ?></font>
<?php
} else {
?>
<br><br>
<font size="-1">No records found!</font>
<br><br>
<?php
}
}

?>
         </div>

<br style="clear: both;" />

</div>
</div>

</body>
</html>
I can get you some info about the database structure, but what exactly do you need? Just how the table is set up?

Thanks!


**EDIT** I just attached 2 screenshots of the database structure.
Attached Images
File Type: png Picture 1.png (105.8 KB, 4 views)
File Type: png Picture 2.png (34.6 KB, 3 views)
__________________
Webmaster-Talk Rules

Last edited by angele803; 03-26-2008 at 04:31 PM..
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-26-2008, 05:53 PM Re: Transferred Host, Can't get database info
tripy's Avatar
Do not try this at home!

Posts: 3,139
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
The HTTP_SESSION_VARS, $HTTP_POST_VARS and $HTTP_GET_VARS are deprecated and replaced by $_SESSION, $_POST and $_GET.
They are still supported, but they can be disabled on the server configuration:
http://www.php.net/manual/en/languag...s.superglobals
Quote:
Also, you'll notice how the older predefined variables ($HTTP_*_VARS) still exist. As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.
First, try to do an echo of your sql query, and run it in phpmyadmin. If they are result, then try a search & replace on those $HTTP_*_VARS variables
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-27-2008, 12:35 PM Re: Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
Thank you so much! That made a big difference.

The only problem left is that if you search for something that has a "sub" value, it doesn't show up. For example, click on "ford", then click on either "pickups", "suvs", or "vans". Nothing shows up. It should display something similar to what displays when you select "nissan".

Is there another depreciated tag in there somewhere?? Any other ideas why it isn't working?
__________________
Webmaster-Talk Rules
angele803 is offline
Reply With Quote
View Public Profile
 
Old 03-28-2008, 02:56 PM Re: Transferred Host, Can't get database info
angele803's Avatar
Perfectly Imperfect

Posts: 1,766
Name: Stephanie
Location: Oklahoma
Trades: 2
So I finally figured out the last problem. Just in case you are curious, it was because the previous programmer used a plain variable to call the variable from the link. Since I switched to a hosting account that is using php5, I had to change those variables to $_Get[variable]/

Thanks for all your help!!
__________________
Webmaster-Talk Rules
angele803 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Transferred Host, Can't get database info
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.33530 seconds with 14 queries