MDobleZ Posted December 31, 2012 Share Posted December 31, 2012 html tags appear when I retrieve info from a table. This is my .js: function receive() { var xmlhttp=false; xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","step2.php",false); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("answer").innerText=xmlhttp.responseText; } } xmlhttp.send(); } And this is my .php: <html> <body> <?php $con2=mysql_connect("sql108.getfreehosting.co.uk","getfh_6562567","19770514"); mysql_select_db("getfh_6562567_fch",$con2); $result=mysql_query("SELECT message FROM chat WHERE Id=1"); $row=mysql_fetch_array($result); echo $row[0]; mysql_close($con2); ?> </body> </html> What am I doing wrong? Thanks. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 31, 2012 Share Posted December 31, 2012 (edited) What am I doing wrong? Besides posting your database credentials in a public place? You're not looking at your PHP code, that's what you're doing wrong. Look at it. <html> <body> <?php $con2=mysql_connect("...", "...", "..."); mysql_select_db("...",$con2); $result=mysql_query("SELECT message FROM chat WHERE Id=1"); $row=mysql_fetch_array($result); echo $row[0]; mysql_close($con2); ?> </body> </html> Edited December 31, 2012 by requinix Quote Link to comment Share on other sites More sharing options...
MDobleZ Posted December 31, 2012 Author Share Posted December 31, 2012 Sorry, but aside from my "come-and-hack-me-I'm-an-idiotic-newbie" move, I see nothing strange in the code. I know that it contains html tags, but so do all the examples I've seen online. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 31, 2012 Share Posted December 31, 2012 At some point you have to start moving away from the examples. They are, after all, just examples. If you don't want to include HTML tags (as it should not) then don't have them in there. Quote Link to comment Share on other sites More sharing options...
MDobleZ Posted December 31, 2012 Author Share Posted December 31, 2012 Thank you very, requinix, I will. 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.