Warprunner Posted December 10, 2013 Share Posted December 10, 2013 I am doing a search engine for free for a Autism site. I am having a problem with a php query returning an embedded link from a MySql db. The issue is it returns http://mysitename.com and then concatenates the link I had put in which is http://www.ada.com In the db Text field it is : <a href="http://www.ada.com" target="_blank">The Americans with Disabilities Act </a>was enacted in 1990 to establish the prohibition of discrimination.... Results are the link goes to http://www.mysitename.com/"www.ada.com" (Please notice the quotes as well). I don't know why it's putting in mysitename.com or why it's putting quotation marks around the real link or lastly why it's making my link a sub folder of mysitename.com. Pic of the results: Here is the code: <?php // create short variable names $searchtype=$_POST['searchtype']; $searchterm=trim($_POST['searchterm']); if (!$searchtype || !$searchterm) { echo '<p><strong>You have not entered search details. Please go back and try again.</strong></p>'; exit; } if (!get_magic_quotes_gpc()){ $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } @ $db = new mysqli("*","*","*","*"); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from acronymns where ".$searchtype." like '%".$searchterm."%' ORDER BY title "; $result = $db->query($query); $num_results = $result->num_rows; echo "<p>Number of records found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc(); echo "<p><strong>".($i+1).". "; echo $row['acro']; echo " - "; echo $row['title']; echo "</strong><br />"; echo $row['desc']; echo "</p>"; } // $result->free(); $db->close(); ?> Thank you ahead of time.... this is really driving me nuts! Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/ Share on other sites More sharing options...
requinix Posted December 10, 2013 Share Posted December 10, 2013 Are you absolutely, definitely, 100% sure that In the db Text field it is : The Americans with Disabilities Act was enacted in 1990 to establish the prohibition of discrimination.... is exactly how it is in the database? I don't think it is, partly because I can't help but notice that the screenshot shows something different from what you said. I think you have something more like Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461899 Share on other sites More sharing options...
Warprunner Posted December 10, 2013 Author Share Posted December 10, 2013 Here is straight from the DB : The <a href=”http://www.ada.gov” Target="_blank"> Americans with Disabilities Act </a> was enacted in 1990 to establish the prohibition ... Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461907 Share on other sites More sharing options...
jazzman1 Posted December 10, 2013 Share Posted December 10, 2013 (edited) Maybe the output starts with "/" which is the domain name root directory because of the result using addslashes Could you post out the echo of: $query = "select * from acronymns where ".$searchtype." like '%".$searchterm."%' ORDER BY title "; echo $query; exit; Edited December 10, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461910 Share on other sites More sharing options...
requinix Posted December 10, 2013 Share Posted December 10, 2013 The Americans with Disabilities Act was enacted in 1990 to establish the prohibition ...Smart quotes. Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461915 Share on other sites More sharing options...
PravinS Posted December 10, 2013 Share Posted December 10, 2013 "http://" may be missing, please check that Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461921 Share on other sites More sharing options...
requinix Posted December 10, 2013 Share Posted December 10, 2013 "http://" may be missing, please check thatIt is clearly not. Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461922 Share on other sites More sharing options...
Warprunner Posted December 10, 2013 Author Share Posted December 10, 2013 Maybe the output starts with "/" which is the domain name root directory because of the result using addslashes Could you post out the echo of: $query = "select * from acronymns where ".$searchtype." like '%".$searchterm."%' ORDER BY title "; echo $query; exit; Here is the Echo: select * from acronymns where title like '%ada%' ORDER BY title Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461961 Share on other sites More sharing options...
Warprunner Posted December 10, 2013 Author Share Posted December 10, 2013 The <a href=”http://www.ada.gov” Target="_blank"> Americans with Disabilities Act </a> was enacted in 1990 to establish the prohibition ...Smart quotes. Can you explain?? Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1461962 Share on other sites More sharing options...
requinix Posted December 10, 2013 Share Posted December 10, 2013 You can't use smart quotes in HTML markup. Only straight quotes. Your browser is silently interpreting that HTML as The Americans with Disabilities Act was enacted in 1990 to establish the prohibition ... Quote Link to comment https://forums.phpfreaks.com/topic/284670-help-to-get-inline-html-to-show-correctly/#findComment-1462001 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.