Davidammit Posted August 16, 2008 Share Posted August 16, 2008 I'm trying to get a website going that will have a search on every page. I got the PHP part working...but now the JavaScript Part doesn't even want to run. I bet I screwed up somewhere. To test if it was a problem with the server I moved another piece of JavaScript that I knew would work to its own file, so now I know that its just the code. But then I tested it with code straight from a tutorial site, to see if that would run, and it didn't either, so maybe the site isn't compatible with ResponseXML requests? Instead of posting all the code here, I think I'll just link to the source files. http://weareotaku.x10hosting.com/ http://weareotaku.x10hosting.com/search.js http://weareotaku.x10hosting.com/search.php The only searchable things in the database right now are rosario + vampire to I just made it as a test, and I know that the PHP does work, cuz it returns the proper XML for what I need the JavaScript to do. Thank you in advance for any help. Quote Link to comment Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 I momentarily forgot PHP was serverside only. Here's the code <?php $q=$_GET["search"]; $con = mysql_connect('localhost', 'waotaku_search', 'abc123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("waotaku_anime", $con); $sql="SELECT title, link, embed, added, MATCH(title, keywords) AGAINST('" . $q . "') AS relevance FROM animelist WHERE episode=0"; $result = mysql_query($sql); echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; for($row = mysql_fetch_array($result); $row != null; $row = mysql_fetch_array($result)) { echo '<person>'; echo "<title>" . $row['title'] . "</title>"; echo "<link>" . $row['link'] . "</link>"; echo "<embed>" . $row['embed'] . "</embed>"; echo "<added>" . $row['added'] . "</added>"; echo "</person>"; } mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 well I finally fixed that problem on my own, but now its not carrying out the document.getElementById("searchresults").innerHTML=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue; Quote Link to comment Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 i've narrowed it down to the part that refers to the xmlDoc. Since when i just do the document.getElementById("searchresults").innerHTML="OMFG WHY WON'T U WORK!!!"; it displays it. Quote Link to comment Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 well I found a way around the problem by formatting the text on the PHP side and useing responseText instead of responseXML...but this may prove to be a problem later. 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.