Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/u518531470/public_html/chatsaza/personal.php on line 16
<?php
session_start();
if (!isset ($_SESSION['login'])) {header("Location:index.php");}
$to2 = $_SESSION['login'];
include './db.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Решаем экзамен</title>
</head>
<body>
<?php
echo "HELLO, ".$_SESSION['login']."! <a href='logout.php'>EXIT!</a><br><br>";
$result = mysql_query ("SELECT * FROM `chat` WHERE to = $to2",$db); // ТУТ ОШИБКА
while($myrow = mysql_fetch_assoc ($result)){
echo "<table cellpadding='0' cellspacing='0'>
<tr>
<td><h3><a href='letter.php?to=".$myrow['from']."'>".$myrow['from']."</a> ".$myrow['date']."</h3></td>
</tr>
<tr>
<td><p>".$myrow['text']."</p></td>
</tr>
</table>";
}
?>
<form action="personal.php" name="refresh">
<input type="submit" value="Обновить!">
</form>
<br><br>
<form action="komment.php" name="form1" method="post">
<input type="hidden" name='login' value="<?php echo $_SESSION['login']; ?>">
<input type="hidden" name='public' value="1">
<label>Текст<br></label>
<textarea name="text" cols="25" rows="5"></textarea><br>
<input type="submit" value="Коммент!">
</form>
</body>
</html>
Помогите исправить)
Спустя 5 минут, 39 секунд (30.05.2012 - 14:53) rooor написал(а):
$result = mysql_query ("SELECT * FROM `chat` WHERE to = $to2",$db) or die(mysql_error());
if(mysql_num_rows($result) > 0)
{
while($myrow = mysql_fetch_assoc ($result)){
Спустя 17 минут, 24 секунды (30.05.2012 - 15:10) olzagafer написал(а):
не хочет опять, но ошибка теперь такая
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to=saza-diz' at line 1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to=saza-diz' at line 1
Спустя 4 минуты, 18 секунд (30.05.2012 - 15:14) rooor написал(а):
$result = mysql_query ("SELECT * FROM `chat` WHERE `to` = '".mysql_real_escape_string($to2)."'",$db) or die(mysql_error());
Спустя 3 минуты, 31 секунда (30.05.2012 - 15:18) olzagafer написал(а):
спасибо, помогло!!!