Merhaba arkadaşlar, ufak blogumsu bir şey yapıyorum. Türkçe karekterle ilgili sorun yaşıyorum. Jquery den dolayımı bu hatayı alıyorum anlamadım.
Hata sayfası:
Buraya tıklayın.
Dosyaları veriyorum, nerede hata var, veya ne eklemem gerekiyor. Lütfen bir el atın. 3 dosya var. İnternette buldum.
index.php, fetch_pages.php, config.inc.php
Veritabanı kodlaması , karşılaştırması : utf8_general_ci
index.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax Load results from Database</title>
<style type="text/css">
button {padding: 8px 20px;background: #fbfbfb;border: 1px solid #ddd;border-radius: 4px;height: 37px;min-width: 130px;}
button:hover, button:active, button:focus{background: #f3f3f3;outline: none;}
</style>
</head>
<body>
<div class="wrapper">
<ul id="results"><!-- results appear here --></ul>
<div align="center">
<button id="load_more_button"><img src="ajax-loader.gif" class="animation_image" style="float:left;"> Load More</button> <!-- load button -->
</div>
</div>
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
var track_page = 1; //track user click as page number, righ now page number 1
load_contents(track_page); //load content
$("#load_more_button").click(function (e) { //user clicks on button
track_page++; //page number increment everytime user clicks load button
load_contents(track_page); //load content
});
//Ajax load function
function load_contents(track_page){
$('.animation_image').show(); //show loading image
$.post( 'fetch_pages.php', {'page': track_page}, function(data){
if(data.trim().length == 0){
//display text and disable load button if nothing to load
$("#load_more_button").text("Yolun sonuna geldin.").prop("disabled", true);
}
$("#results").append(data); //append data into #results element
//hide loading image
$('.animation_image').hide(); //hide loading image once data is received
});
}
</script>
İİİŞİŞ-ĞÜÇ.çççöÖ
</body>
</html>fetch_pages.php
<?php
include("config.inc.php"); //include config file
//sanitize post value
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
//throw HTTP error if page number is not valid
if(!is_numeric($page_number)){
header('HTTP/1.1 500 Invalid page number!');
exit();
}
//get current starting point of records
$position = (($page_number-1) * $item_per_page);
//fetch records using page position and item per page.
$results = $mysqli->prepare("SELECT id, tarih, baslik, icerik FROM icerikler ORDER BY id DESC LIMIT ?, ?");
//bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
//for more info https://www.sanwebe.com/2013/03/basic-php-mysqli-usage
$results->bind_param("dd", $position, $item_per_page);
$results->execute(); //Execute prepared Query
$results->bind_result($id, $tarih, $baslik, $icerik); //bind variables to prepared statement
//output results from database
while($results->fetch()){ //fetch values
echo ''.$tarih.' - '.$baslik.'<br>'.$icerik.'<br>';
}
?>config.inc.php
<?php
$db_username = 'Gizlendi';
$db_password = 'Gizlendi';
$db_name = 'Gizlendi';
$db_host = 'localhost';
$item_per_page = 5;
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
//Output any connection error
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
?>