Darkmatter5 Posted April 29, 2008 Share Posted April 29, 2008 Here are the three snippets of code that I'm using. I have a text box with a button that launches a function in the javascript and displays a result at a div in the search.php file. The problem is when I click the button the result I get is "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[object HTMLFormElement]' at line 3". Can someone please help me diagnose this error? search.php <form><div align="center" class="style7"><span class="style6"> <label>Search by LastName: <input name="LastName" type="text" id="LastName" /></label></span> <input name="searchclients" type="button" id="searchclients" onclick="showClientTXT(this.form)" value="Search" /> </div></form> select_TXTsearchclients.js // JavaScript Document var xmlHttp function showClientTXT(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="http://byrndb01/byrndb/library/get_TXTsearchclients.php" url=url+"?r1="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("results").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml12.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } get_TXTsearchclients.php <?php $lastname=$_GET["r1"]; include 'dbconfig.php'; include 'opendb.php'; $query="SELECT ClientID, FirstName, LastName, CompanyName, HomePhone, WorkPhone FROM byrnjobdb.clients WHERE LastName=$lastname"; $result=mysql_query($query) OR die (mysql_error()); echo "<table border='1'> <tr> <th>ClientID</th> <th>First Name</th> <th>Last Name</th> <th>Company Name</th> <th>Home Phone</th> <th>Work Phone</th> </tr>"; while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td><a href='addclient.php' target='mainFrame'>" . $row['ClientID'] . "</a></td>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['CompanyName'] . "</td>"; echo "<td>" . $row['HomePhone'] . "</td>"; echo "<td>" . $row['WorkPhone'] . "</td>"; echo "</tr>"; } echo "</table>"; include 'closedb.php'; ?> Quote Link to comment Share on other sites More sharing options...
priti Posted April 30, 2008 Share Posted April 30, 2008 SELECT ClientID, FirstName, LastName, CompanyName, HomePhone, WorkPhone FROM byrnjobdb.clients WHERE LastName=$lastname Kindly run this in your query interface i think you have error somewhere here. special in "FROM byrnjobdb.clients" i.e if you are keeping table aliases then byrnjobdb as clients i.e tablename as alias hope it help to solve your query. Gr8 day!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.