Jump to content

[SOLVED] "undefined" driving me crazy


cleary1981

Recommended Posts

Ive went through this several times now and getting nowhere.

 

heres the main html file

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>TES - Pricing System</title>
<link rel="stylesheet" type="text/css"
href="style.css" />

</script>
<script type="text/javascript" 
        src="prototype.js"></script>
<script type="text/javascript"
        src="scriptaculous.js"></script>
<script language="javascript" src="list.php"></script>
<script type="text/javascript" src="getdimensions.js"> </script>
<script type="text/javascript" src="text-utils.js"> </script>



<script type="text/javascript">
window.onload = function() {
     new Draggable('object', {snap:25} );
fillCategory();
}

var request = null;

try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
	request = null;
	}

}
}
if (request == null)
alert("Error creating XMLHttp Request!");

function get_description() {
var model = document.getElementById("model").value;


var url = "lookupdescription.php?model=" + escape(model);

request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}

function updatePage() {
if (request.readyState ==4) {
var modeldescription = request.reponseText;
var x = document.getElementById("description");
replaceText(x, modeldescription);

}
}

</script>


</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

<div id="container">
<div id="top">
	<h1>TES - Pricing System (Design Mode)</h1>
</div>

<div id="leftSide">
	<fieldset>
	<legend>Module</legend>
	<FORM name="drop_list">
	<label for="type">Type</label>
	<div class="div_texbox">
		<SELECT  NAME="Category" onChange="SelectSubCat();" >
		<Option value="">Select Type</option>
		</SELECT>
	</div>
  		<label for="mod_named">Model</label>
    		<div class="div_texbox">
		<SELECT id="model" NAME="SubCat" onChange="get_description();">
		<Option value="">Select Model</option>
		</SELECT>
	</div>
	<fieldset>
	<legend>Description</legend>
	<span id="description">description goes here</span>

	</fieldset>
	<label for="mod_name">Name</label>
    		<div class="div_texbox">
    			<input name="username" type="text" class="username" id="username" value="" />
	</div>
	<div class="button_div">
		<input name="Submit" type="button" value="Generate" class="buttons" onClick="generate_module()"/>
	</div>
	</form>
	</fieldset>

	<fieldset>
	<fieldset>
	<legend>Delete</legend>
	</fieldset>
	<fieldset>
	<legend>Generated Module</legend>
	<img id="object">
	</fiedset> 
	</fieldset>	
</div>


<div id="content">
	<div id="drop_area">

	</div>
</div>  

  	<div class="clear"></div>
</div>

</body>
</html>

 

heres my php

<?php

require "config.php";


$model = preg_replace("/[\. \(\)\-]/", "", $_REQUEST['model'];
$select = 'SELECT mod_desc';
$from = ' FROM module';
$where = ' WHERE type = \'' . $model' . '\'';

$queryResult = mysql_query($select . $from . $where) or die("Error!".mysql_error());

echo $queryResult;


mysql_close($conn);
?>

 

 

I'm sure the javascript part is all ok. Think the problem lies in the php somewhere.

Sorry i didn't make that clear. span id=description where I expect the description to appear displays "undifined instead".

 

if i run the php code directly in the browser i get the following error

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\lookupdescription.php on line 9

(line 9: $where = ' WHERE type = \'' . $model' . ''';)

Archived

This topic is now archived and is closed to further replies.

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