Hi All,
I have an ajax datagrid that displays a list of items in the customer's cart, and lets them edit these quantities, which then updates the database.
It works perfectly on my personal Abyss Web Server on localhost. But when I upload it to my www.winhost.com servers, it never displays the grid! It's the exact same code! I don't know what to do, I have tried everything I could think of. Any help at all is appreciated, Please help!
Thanks!
jase
The site: http://www.onestopfasteners.com.au/checkout.php
The Code
?php // Start the session.
session_start();
?>
<!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/creative.css">
<title>Mild Steel Products | One Stop Fasteners</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/jquery.tools.min.js"></script>
<script type="text/javascript" src="js/cufon.js"></script>
<script src="js/Kozuka_Gothic.js" type="text/javascript"></script>
<!-- Fix for Internet Explorer 9 Beta -->
<!--[if gte IE 9]>
<script type="text/javascript">
Cufon.set('engine', 'canvas');
</script>
<![endif]-->
<script type="text/javascript" charset="utf-8">
// <![CDATA[
$(document).ready(function(){
Cufon.replace('h1,h2,h3', {
});
$(function() {
$("h3.message").delay(3000).fadeOut();
});
});
// ]]>
</script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/creative_table.min.js"></script>
<script type="text/javascript" src="js/creative_table_ajax.min.js"></script>
</head>
<body>
<div class="main">
<div class="header">
<div class="logo"><a href="index.php"><img src="images/logo.png" border="0" alt="logo" /></a></div>
<div class="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="products.php">Order Online</a></li>
<li><a href="products.php" class="active">Products</a></li>
<li><a href="about.php">About us</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div class="clr"></div>
</div>
<div class="header_text2">
<h2> Checkout</h2>
<p>Adjust your quantities, then click purchase. </p>
<div class="clr"></div>
</div>
<div class="clr"></div>
<div class="top_sup_resize">
<div class="menu2">
<ul>
<!--<li><a href="mildsteel_allthread.php" style="font-size:x-small; color:white;">Allthread</a></li>
<li><a href="mildsteel_hexnuts.php" style="font-size:x-small; color:white;">Hex Nuts</a></li>
<li><a href="mildsteel_washers.php" style="font-size:x-small; color:white;">Washers</a></li>
<li><a href="mildsteel_hnbkss.php" style="font-size:x-small; color:white;">Hex Bolt & Nut Kits, Setscrews</a></li>
<li><a href="mildsteel_screws.php" style="font-size:x-small; color:white;">Screws</a></li>
<li><a href="mildsteel_last.php" style="font-size:x-small; color:white;">Cup Head Bolts & Nuts</a></li>-->
</ul>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
<div class="body">
<div class="body_left">
<h2><a href="SEND SESSIONID">Proceed to Checkout</a> </h2>
<h3 class="message"></h3>
<!--div id="container"-->
<?php
if( !isset($_SESSION['last_access']) || (time() - $_SESSION['last_access']) > 71200 )
$_SESSION['last_access'] = time();
//$db = "";
//$tbl = "";
//==============================================================================
// OPTIONS (comment line out to disable option)
//==============================================================================
$db_host='my01.com';
$db_user=;
$db_pass=;
//allow db updates (assumes first column is the primary key of the table)
$option_db_allow_update=1;
//delay answering ajax requests (demonstrates the first "A" in AJAX)
$option_delay_seconds=1;
//all ajax requests are logged to this file
$option_ajax_log_file="./ajax_log.txt";
ini_set("display_errors", "1");
ini_set("error_reporting", "E_ALL");
//==============================================================================
// DB CONNECT
//==============================================================================
extract($_GET);
mysql_connect($db_host,$db_user,$db_pass);
if(!$db)
{
echo "<h3>Select Database</h3>";
$result=mysql_list_dbs();
while ($row = mysql_fetch_row($result))
echo "<a href=\"?db=$row[0]\">$row[0]</a><br>";
exit();
$db = "mysql_9269_dbase";
}
mysql_select_db($db);
//==============================================================================
// AJAX HANDLER
//==============================================================================
if($_POST['ajax'])
{
if($option_ajax_log_file)
{
$open = fopen($option_ajax_log_file, 'a');
fwrite($open, serialize($_REQUEST));
fwrite($open, "\r\n");
fclose($open);
}
extract($_POST);
switch($ajax)
{
case 'nav':
/*
AJAX 'nav' request variables:
$ajax: the ajax command ('nav')
$tbl: table name
$pos: new position (1 based)
$sortcol: columnname to sort on
$sortdesc: set to 1 if sort descending
the AJAX reply is the new table body
*/
$at=BuildTable($db,$tbl,$pos,$sortcol,$sortdesc);
echo $at->GenerateTableSpan();
break;
case 'updcell':
/*
AJAX 'updcell' request variables:
$ajax: the ajax command ('updcell')
$tbl: table name
$rowid: row id
$colid: columnname
$new: the new cell value that was typed into the text input
$old: old value
the AJAX reply is the error message, or empty on success
*/
//update the database
if($option_db_allow_update)
{
//NOTE: assumes first column is the primary key of the table
$col_rowid=mysql_field_name(mysql_query("SELECT * FROM '$tbl' LIMIT 1"),0);
$sql = "UPDATE '$tbl' SET '$colid'='$new' WHERE '$col_rowid'='$rowid' LIMIT 1";
//uncomment next line for strict updates [updates only if data was not changed by another session]
//$sql = "UPDATE '$tbl' SET '$colid'='$new' WHERE '$colid'='$old' AND '$col_rowid'='$rowid' LIMIT 1";
if(!mysql_query($sql))
echo mysql_error() . " in $sql";
elseif(mysql_affected_rows()==0)
echo "Database table update failed.";
}
else
{
echo 'Database updates are disabled in example_mysql.php. set $option_db_allow_update to enable.';
}
break;
default:
echo 'Unknown AJAX cmd';
}
if($option_delay_seconds) sleep($option_delay_seconds);
exit();
}
//==============================================================================
// REGULAR PAGE OUTPUT
//==============================================================================
setcookie("testcookie","1234"); //test cookie for AJAX requests
if(!$tbl)
{
echo "<h3>Select Table</h3>";
$result = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_row($result))
echo "<a href=\"?db=$db&tbl=$row[0]\">$row[0]</a><br>";
exit();
}
echo "<h3>Table $db.$tbl</h3>";
if($option_delay_seconds) echo "To edit quantities, simply click the quantity you wish to edit, type a new value, then click outside the table to persist your changes.<br>";
echo "<br>";
$ta=BuildTable($db,$tbl);
echo $ta->GenerateTable();
//==============================================================================
// FUNCTIONS
//==============================================================================
function BuildTable($db,$tbl,$pos=1,$sortcol='',$sortdesc=0)
{
$pospage=8;
//the display properties for the odd and even rows
$odd = array('style' => 'background-color: #CCCCCC;');
$even = array('style' => 'background-color: #EEEEEE;');
//the display properties for the overall table
$table = array('cellpadding' => '3', 'cellspacing' => '0');
//table column header formatting properties
$headerattrib = array('style' => 'background-color: skyblue; cursor:pointer;');
//get data and rowcount
$possql=$pos-1;
if($sortcol) $orderby=" ORDER BY $sortcol ".($sortdesc?'DESC':'');
$result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM $tbl WHERE sessionid='".session_id()."' $orderby LIMIT $possql,$pospage");
$poscnt = mysql_result(mysql_query("SELECT FOUND_ROWS()"),0,0);
while ($row = mysql_fetch_assoc($result)) $data[]=$row;
//build the datagrid
require_once("./AjaxDataGrid.class.php");
$at = new DataGrid($data,$_SERVER['PHP_SELF']."?db=$db");
$at->JsClass=$tbl;
$at->pos=$pos;
$at->pospage=$pospage;
$at->poscnt=$poscnt;
$at->SetEvenRowAttribs($even);
$at->SetOddRowAttribs($odd);
$at->SetTableAttribs($table);
$at->SetHeaderAttribs($headerattrib);
//NOTE: the columns types are setup automatically - first column readonly,
//rest text. See example.php for setting up columns manually.
return $at;
}
?>
<!--/div-->
</div>
<p> </p></div>
<div class="clr"></div>
</div>
</div>
<div class="footer">
<div class="footer_resize">
<ul>
<li><a href="index.php">home</a></li>
<li><a href="products.php">order online</a></li>
<li><a href="products.php">products</a></li>
<li><a href="about.php">about</a></li>
<li><a href="contact.php">contact</a></li>
</ul>
<p>Copyright © 2010, <a href="http://www.onestopfasteners.com.au/">One Stop Fasteners®</a>. All Rights Reserved</p>
<div class="clr"></div>
</div>
</div>
</body>
</html>
I can confirm the following: 1. The database queries work (because they work on my local server)
Originally asked by: Lucifer on Stack Overflow


Answers