Cheszy Posted March 16, 2011 Share Posted March 16, 2011 I've got search script, but when I add I'm I get I\'m. I've tried everything (' , ’ , etc..) but nothing works... Can anyone help me with it? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/ Share on other sites More sharing options...
kenrbnsn Posted March 16, 2011 Share Posted March 16, 2011 Look at stripslashes() & mysql_real_escape_string() (if you're using mysql). Ken Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188212 Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2011 Share Posted March 16, 2011 And check to see if magic_quotes_gpc() et al are set to On. If so, turn them off if you're able to do so. Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188221 Share on other sites More sharing options...
Cheszy Posted March 16, 2011 Author Share Posted March 16, 2011 I tried it, but I'm not so good in PHP/MYSQL Nothing is working Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188246 Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2011 Share Posted March 16, 2011 You're going to need to post the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188254 Share on other sites More sharing options...
kenrbnsn Posted March 16, 2011 Share Posted March 16, 2011 Please post your code between tags. Ken Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188255 Share on other sites More sharing options...
Cheszy Posted March 16, 2011 Author Share Posted March 16, 2011 It's a search script (adding links etc. with the hand)! <?PHP //### Maximum results per page $maxPerPage = 20; if(isSet($_GET['query']) && strlen($_GET['query']) >= 1 ) { include('connection.php'); //### Get and filter the search term entered $searchTerm = mysql_real_escape_string($_GET['query']); $searchTerm = explode(' ',$searchTerm); $termCount = 0; foreach($searchTerm AS $term) { $termCount++; if($termCount == 1) { $query .= " WHERE keywords LIKE '%$term%' "; } else { $query .= " OR keywords LIKE '%$term%' "; } } //### Count total results $totalResults = mysql_num_rows(mysql_query("SELECT * FROM search_links ".$query."")); if(!$totalResults) {echo 'We could not find any results to match your search query.'; exit; } //### Get inital starting point for records $start = isSet($_GET['s']) ? (int)$_GET['s'] : 0 ; if($start > $totalResults-1) { $start = $totalResults-1; } //### Configure the next a prev links to conform with result count $next = ($start+$maxPerPage)>=$totalResults ? $totalResults-1 : $start+$maxPerPage ; $prev = ($start-$maxPerPage)<0 ? 0 : $start-$maxPerPage ; //### Now we do the search for the results $doSearch = mysql_query("SELECT * FROM search_links ".$query." LIMIT $start,$maxPerPage"); echo '<title>avata.rs - Search: ',implode(' ',$searchTerm),'</title>'; if(mysql_num_rows($doSearch)) { echo 'Results for "<span class="result">',implode(' ',$searchTerm),'</span>".<br><br>'; while($result = mysql_fetch_assoc($doSearch)) { echo '<div class="results">'; echo '<span class="resulth"><a href="',$result['link'],'">',$result['title'],'</a></span> - <span class="resultd">',$result['description'],'</span><br>'; echo ''; echo '<span class="resultl">',$result['link'],''; echo '</div>'; } echo '<a href="search.php?query=',implode(' ',$searchTerm),'&s=',$prev,'"><<Previous</a> '; echo '<a href="search.php?query=',implode(' ',$searchTerm),'&s=',$next,'">Next>></a>'; } else { //### No results so we tell them and offer another search echo 'We could not find any results to match your search query.'; exit; } } else { header('Location: index.html'); exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188259 Share on other sites More sharing options...
Maq Posted March 16, 2011 Share Posted March 16, 2011 As Ken pointed out, do not double post. I deleted your duplicate, don't do it again. Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188361 Share on other sites More sharing options...
Cheszy Posted March 16, 2011 Author Share Posted March 16, 2011 I'm sorry Quote Link to comment https://forums.phpfreaks.com/topic/230816-problem-with/#findComment-1188363 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.