Jump to content

maweber98

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by maweber98

  1. maweber98

    PHP AJAX Help

    I found the problem. It was in the javascript code var url section. I was building the url wrong. It shoud be as follows: var url="getcustomer.php?ID="url=url+""+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true)xmlHttp.send(null)} Maybe this will help someone else out that is having trouble. Thanks
  2. maweber98

    PHP AJAX Help

    I'm having trouble getting an AJAX applications working. I'm using the W3Schools AJAX database tutorial as a model, but I'm using PHP instead of ASP. I have gotten to the point where Javascript is calling the PHP file to query the mysql database, but the query always comes back with no values. The mysql database structure is as follows:CREATE TABLE pro_long_description ( ID int(11) NOT NULL auto_increment, Long_Description text NOT NULL, PRIMARY KEY (ID), FULLTEXT KEY Long_Description (Long_Description)) TYPE=MyISAM; var url="getcustomer.php"url=url+"?q="+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true)xmlHttp.send(null) The PHP "getcustomer.php" file is as follows: $con = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Could not connect");mysql_select_db($dbname);$cid = $_GET['ID'];//error$XX = "Description Not Found\n"; $sql= mysql_query("SELECT * FROM coas50.pro_long_description WHERE ID='$cid'");$result = mysql_query($sql);while ($row = @mysql_fetch_array($sql)) { $variable15=$row['Long_Description']; //table layout for results print ("<p>$variable15</p><br><br>");}//below this is the function for no record!!if (!$variable15){ print ("$XX");} I don't think I'm getting the $cid value because all I get from the query is my error message "Description Not Found". Could this be a problem in the way I created the drop down menu? I'm using a query to dynamically build the drop down menu on this page. $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["ID"]; $long_description_ex=$row["Long_Description"]; $options.="<OPTION VALUE=\"$id\">".$long_description_ex.'</option>';} ?> <select name= "long_description_ex" id="long_description_ex" onchange="showCustomer(this.value)"> <option value="">-- Choose From Existing Description -- <?=$options?> </option> </select> <p><div id="txtHint">The full description will be listed here</div></p> <p>or add new description</p> <textarea name="Long_Description_New" id="Long_Description_New" cols="57" rows="10"></textarea> <div class=error id=Long_Description_NewError>Required: Please enter Description<br></div><br></td> Anyone have any ideas what may be going wrong here. I have narrowed down that javascript file is making the call to the query and I'm getting a response back "Description Not Found" so I'm guessing the issue is in how the query string is being built. Thanks for your time!!
×
×
  • Create New...