rhock_95 Posted November 27, 2007 Share Posted November 27, 2007 $sql="select * from table where name='$name' and title='$query' ORDER BY name"; My problem is the above query works fine unless the data in the "title" column has an "&" in the text...then the script does not display any results...is there a way to correct this with the query or do I have to change the records? TIA Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 sample data ? so we can build a query for yahh Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 27, 2007 Share Posted November 27, 2007 $title= mysql_real_escape_string($title); $title= strip_tags($title); make sure to safely remove special characters from being entered Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 27, 2007 Author Share Posted November 27, 2007 Not sure that would work because the & is actually in the title (data) as part of the record. This particular script runs inside the results of a parent script... it allows the user to display all the names with the same "title"... ...the parent script originally returns all the names and titles Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 27, 2007 Share Posted November 27, 2007 $sql="select * from table where name='$name' & title='$query' ORDER BY name"; Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 if you dont want the exact value the use " like " well im confuzed on what your trying to do but you can remove the & trough sql then after removing the & compare it.. Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 27, 2007 Author Share Posted November 27, 2007 you lost me now...can you show me an example of using LIKE with the query posted? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 27, 2007 Share Posted November 27, 2007 You can use LIKE, for example, LIKE 'Hi%' and that will get every word that starts with Hi Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 show titles samples... and your title your trying to compare Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted November 27, 2007 Author Share Posted November 27, 2007 I got it... LIKE '%title%' works like a charm... Thanks for the help... 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.