Death_Magnetic Posted July 31, 2008 Share Posted July 31, 2008 Ok,i'm trying to retrieve some information from a database with AJAX/PHP.But the returned data(responseText) from the server is just the source code of the PHP file.I'm not getting just the results of echo-es.Why?I'm using WampServer and maybe it's something with the PHP,i mean it's not properly installed or something.Actually when i go to the 'www' directory of the server and open only the PHP file in the browser directly from there the result is the same,the page contains the source code of the file.So,the address in the address bar of the browser is "file:///C:/wamp/www/products.php".But when i open the same file by typing "http://localhost/products.php" in the address bar everything is ok.I'm confused,i'm very new to web programming so please tell me what's wrong.Here is the javascript and php code i'm using: <script> function http(){ try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp; } var xmlHttp = http(); function getInformation() { xmlHttp.onreadystatechange = changeContent; xmlHttp.open("GET","HTML_editor.HTML",true); xmlHttp.Send(null); } function changeContent(){ if (xmlHttp.readyState==4){ document.getElementById("d").innerHTML=xmlHttp.responseText; } } getInformation(); </script> <?php $connection = mysql_connect('localhost','root',''); if(!mysql_select_db('products')) { exit(mysql_error()); } $result = mysql_query('SELECT * FROM boots',$connection) or die(mysql_error()); while($products = mysql_fetch_array($result)) { echo $products['size']; echo $products['price']; } mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
corbin Posted July 31, 2008 Share Posted July 31, 2008 <letter>:\<path> is a protocol (sorta... more like a format, but for simplicity, I'll call it a protocol) that Windows uses to access the filesystem (simplifying again... a lot). http:// is an entirely different protocol prefix (type thingy) that is handled by a web browser, not Windows Explorer (or shell or what ever). Blerh, just look up the wikipedia thingy on the HTTP protocol. If you can't figure it out after some googling, then I'll help ;p. Feeling lazy right now x.x. Quote Link to comment Share on other sites More sharing options...
Death_Magnetic Posted July 31, 2008 Author Share Posted July 31, 2008 Yeah,i know this.I don't want to be rude but my question was about something else.Forget the last 3 lines of my previous post.Thank you anyway. 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.