Loading...
Помощь по скриптам | ошибка? Но все правильно
http://war.warking.mobi/chat вот пример все правильно чат работает как не как но смс не отправляет можете помочь пожалуйста файл ниже
------
56984_chat.php.zip (2.6 Kb)
Скачиваний: 94
вот код в котором может быть ошибка

if(!$err){


mysql_query("INSERT INTO `chat` SET `id_user` = '$user[id]', `time` = '".time()."', `text` = '".text($text)."'");
mysql_query("UPDATE `users` SET `spamanti` = '".(time() + 5)."' WHERE `id` = '".$user['id']."'");
mysql_query("UPDATE `users` SET `chat_read` = '1'");

$_SESSION['msg'] = '<div class="text center"><font color="lime">Сообщение отправлено</font></div>';
header('Location: /chat.php');
exit();
}else{
$_SESSION['msg'] = $err;
header('Location: /chat.php');
exit();
}
}else{
$_SESSION['msg'] = '';
header('Location: /chat.php');
exit();
}

}
if(isset($_GET['delete_post']) and $user['access'] > 0){
mysql_query("DELETE FROM `chat` WHERE `id` = '".$_GET['delete_post']."'");
$_SESSION['msg'] = '<div class="text center"><font color="lime">Сообщение удалено</font></div>';
header('Location: ?');
exit();
}
echo "<table style='width:100%;'><tr><td style='width: 50%;' class='center'><a href='/chat.php?smiles' class='des'><font color='silver'>Смайлы</font></a></td> <td style='width: 50%;' class='center'><a href='/chat.php?md' class='des'><font color='silver'>Модераторы</font></a></td></tr></table></div>";
echo "<div class='text center'>";
if($user['level'] <= 4){
echo "<font color='tomato'>Чат доступен с 5 уровня</font></div>";
}else{



require_once ('modules/smiles_ajax.php');
if(isset($_GET['to'])){
echo "<form method='post' action='' id='ajax_form'>";
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $_GET[to] LIMIT 1"));
echo "<input type='text' name='text' id='sml' value = '$opponent[login], '>";
?> <input class="btn" type="button" onClick="mode('ajax_form');" value="Отправить"> <?
echo "<a href='/chat' class='btn'>Обновить</a></form>";
}else{
echo "<form method='post' action='' id='ajax_form'>";
echo "<input type='text' id='sml' name='text'>";
?> <input class="btn" type="button" onClick="mode('ajax_form');" value="Отправить"> <?
echo "<a href='/chat' class='btn'>Обновить</a>
</form>";
}
}
echo '<div id="indicator"></div><div id="display"></div>';
echo "</div>";
?>

<script type="text/javascript">
function mode(ajax_form)
{
$('#indicator').addClass('ajax_load'); // Подключаем класс
$.ajax({
url: '/include/chat_form_ajax.php', // Название файла обработчика
type: 'POST',
data: jQuery('#ajax_form').serialize(),
success: function(data)
{
$('#indicator').removeClass('ajax_load'); // Отключаем класс
$('#display').html(data);
}
});
}
</script>
<script type='text/javascript'>
/*<![CDATA[*/
function sml(id, html) {
var e = document.getElementById(id);
if (e != null) {
e.value += ' ' + html + ' ';
e.focus();
}
}
/*]]>*/
</script>
<?
$set['p_str'] = 10;
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `chat`"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

echo "<div id='content'>";

$q = mysql_query("SELECT * FROM `chat` ORDER BY `id` DESC LIMIT $start, $set[p_str]");
if($k_post == 0) echo "<div class='text center'><font color='tomato'>Сообщений в чате не обнаруженно</font></div>";
echo '<div class="de">';
while($post = mysql_fetch_assoc($q)) {
echo '<div class="de">';
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));

echo " <font color='#fff'><img src='/icons/".$ank['sex'].".png'><a href='/hero/$ank[id]'> <font color='silver'> $ank[login]</font></a> ";
echo "".tl(time()-$post['time'])."";

$msg = str_replace(array($user['login'].','), "<span style='float:left;'><b><font color='lime'> $user[login]</font>,</b> ", $post['text']);
echo "<br><font size='2' color='#fff'>".text_msg($msg)."</font>";
if($myID != $ank['id'])echo "<br><a href='?msg=$ank[id]'><font color='silver'>[ответить]</font></a></span> ";
if($user['access'] > 0)echo " <a href='?delete_post=$post[id]'><font color='red'>[×]</font></a>";
echo"</font></font>";
echo '</div></div>';
}


echo '</div>';
if ($k_post > 10)
{
echo '<div class="text center">';
str('?',$k_page,$page);
echo "</div>";
}

?>
<script>
function show()
{
$.ajax({
url: "/include/chat_ajax.php?page=<?=$page?>",
cache: false,
success: function(html){
$("#content").html(html);
}
});
}

$(document).ready(function(){
show();
setInterval('show()',1000);
});
</s
и вот кусочек продолжение кода тот что выше

});
</script>
<?
include 'system/footer.php';
?>
while($post = mysql_fetch_assoc($q)) {
echo '<div class="de">';
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));

Запрос в цикле!
Мощно ))
Может более усиленно изучишь БД?)
________
посл. ред. 09.06.2018 в 20:07; всего 1 раз(а); by Trolling
Trolling , аккак исправить его
PHP_SELF , используй связку таблиц
Онлайн: 3
Время:
Gen. 0.0855
(c) Bym.Guru 2010-2026