I am trying to write a custom search page for a client using ajax with php to kind of find all containing "XXX" then selcting a part in the table will give you details below, all is going well using define_page_3.php and a custom jquery script in jscript_parts_lookup,php.
I can enter a partial part number and i lists all results in a table, however when i select the row to show the details, I am having an issue.

Code:
$theProductId = $_POST['pn'];
global $db;

if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
		if (isset($_POST['pn']) === true && empty($_POST['pn']) === false) {
		$sql = 'select * from ' . TABLE_PRODUCTS . ' where products_model like :modelID:';
		$sql = $db->bindVars($sql, ':modelID:', '%' . $theProductId . '%', 'string');
		$result = $db->Execute($sql);
		echo '<table class="prodtable" id="prodtable">';
		echo '<tr class="tbhr"><th width=\'15%\'>PN:</th><th width=\'35%\'> Desc</th><th width=\'5%\'>&nbsp;</th></tr>';
		if ($result->RecordCount() > 0) {
			while (!$result->EOF) {
				echo '<tr>';
				echo '<td>';
			    echo '<p>' . $result->fields['products_model'].'</p>';
			  	echo '</td>';
				echo '<td>';
					$sql = 'select * from ' . TABLE_PRODUCTS_DESCRIPTION . ' where products_id = :productID:';
					$sql = $db->bindVars($sql, ':productID:', $result->fields['products_id'] , 'string');
					$result1 = $db->Execute($sql);
					echo $result1->fields['products_description'];
				echo '</td>';
				echo '</tr>';
			  $result->MoveNext();
			}
		echo '</table>';
		} else {
			echo 'Sorry, no record found for product number ' . $theProductId;
		}
		} else {
			echo 'Please enter a valid part number';
		}
the jscript:

Code:
$("#prodtable tr").mouseover(function(){
				$(this).removeClass('nothighlighted');
				$(this).addClass('highlighted');
			});
			$("#prodtable tr").mouseout(function(){
				$(this).removeClass('highlighted');
				$(this).addClass('nothighlighted');
			});
Code:
var tr = $('#prodtable').find('tr');
            tr.bind('click', function(event) {
                var partnum = '';
                tr.removeClass('highlighted');
                var tds = $(this).addClass('highlighted').find('td');
                var ptxt = $(this).find('p');

                $.each(ptxt, function(index, item) {
					 partnum = partnum + (item.innerText || item.textContent);
                });
               	$.post('../includes/languages/english/html_includes/ojl/define_page_3.php', {partnum: partnum}, function(data){						
						$('#part_detail').html(data);
					});
            });
Now when selecting a row, i get this error:
Fatal error: Call to a member function bindVars() on a non-object in /home/content/xxx/html/includes/languages/english/html_includes/ojl/define_page_3.php on line 48

which is line:
PHP Code:
$sql $db->bindVars($sql':modelID:'$tvalue'string'); 
Which doesnt make any sence to me because what i gather formt the error is that is doesnt see the $db object which is clearly used in the above section of code to make the table?
Any clues? ive been on this 2 days now and its greatly holding me up.
Thanks in advance
Jeff