Что-то беда у меня с запросом в РНР
Код:
$zapr = mysql_query("update articles set theme=$theme, article=$article, author=$author where id_a=$id_a;");
Хотя если в самом MySQL писать запрос, то все работает, может буда с переменными?
Код:
$zapr = mysql_query("UPDATE articles SET author='$author', theme='$theme', article='$article' WHERE id_a='$id_a'");
Короче, если ставить кавычки, то все заработало! Но! Ничего не изменяется в БД ((( Есть мысли?
Цитата:
Originally posted by DissDoc
Исправил!
Короче, если ставить кавычки, то все заработало! Но! Ничего не изменяется в БД ((( Есть мысли?
Исправил!
Код:
$zapr = mysql_query("UPDATE articles SET author='$author', theme='$theme', article='$article' WHERE id_a='$id_a'");
Короче, если ставить кавычки, то все заработало! Но! Ничего не изменяется в БД ((( Есть мысли?
Написано прально. Проверь значения всех переменных в запросе, особенно $id_a
Написано прально. Проверь значения всех переменных в запросе, особенно $id_a [/QUOTE]
Вот собственно id_a и лажает! :P Спасибо за помощь![
Код:
<html>
<head>
</head>
<body>
<?
include "../condb.php";
$ed = mysql_query("select * from articles where id_a=$id_a");
if ($ed) {
$qwerty = mysql_fetch_array($ed);
?>
<table width="100%" border="1" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<th width="100%" bgcolor=#990000 align="center"><font color="white">
Редактирование статьи<font></th>
</tr>
<tr>
<th width="100%" bgcolor=#ffffcc align="center"><font color="black">
<form action=editor.php method=post>
<input type=hidden name=edit value=post>
Название статьи <input type="text" name=theme size=35 value="<?echo $theme=$qwerty['theme'];?>">
Текст
<textarea cols=80 rows=40 name=article><?echo $article=$qwerty['article'];?> </textarea>
Автор <input type="text" name=author size=35 value="<?echo $author=$qwerty['author'];?>">
<input type="submit" value='Редактировать'>
</form>
</font></th>
</tr>
</table>
<?
}
$action = $HTTP_POST_VARS["edit"];
if (!empty($action)) {
$theme = substr($HTTP_POST_VARS["theme"],0,255);
$theme = htmlspecialchars(stripcslashes($theme));
$article = substr($HTTP_POST_VARS["article"],0,255);
$article = htmlspecialchars(stripcslashes($article));
$author = substr($HTTP_POST_VARS["author"],0,255);
$author = htmlspecialchars(stripcslashes($author));
$zapr = mysql_query("UPDATE articles SET author='$author', theme='$theme', article='$article' WHERE id_a='$id_a';");
print "<html><head>\n";
print "<meta http-equiv='refresh' content='0; url=aarticles.php'>\n";
print "</head></html>\n";
}
?>
</body>
</html>
<head>
</head>
<body>
<?
include "../condb.php";
$ed = mysql_query("select * from articles where id_a=$id_a");
if ($ed) {
$qwerty = mysql_fetch_array($ed);
?>
<table width="100%" border="1" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<th width="100%" bgcolor=#990000 align="center"><font color="white">
Редактирование статьи<font></th>
</tr>
<tr>
<th width="100%" bgcolor=#ffffcc align="center"><font color="black">
<form action=editor.php method=post>
<input type=hidden name=edit value=post>
Название статьи <input type="text" name=theme size=35 value="<?echo $theme=$qwerty['theme'];?>">
Текст
<textarea cols=80 rows=40 name=article><?echo $article=$qwerty['article'];?> </textarea>
Автор <input type="text" name=author size=35 value="<?echo $author=$qwerty['author'];?>">
<input type="submit" value='Редактировать'>
</form>
</font></th>
</tr>
</table>
<?
}
$action = $HTTP_POST_VARS["edit"];
if (!empty($action)) {
$theme = substr($HTTP_POST_VARS["theme"],0,255);
$theme = htmlspecialchars(stripcslashes($theme));
$article = substr($HTTP_POST_VARS["article"],0,255);
$article = htmlspecialchars(stripcslashes($article));
$author = substr($HTTP_POST_VARS["author"],0,255);
$author = htmlspecialchars(stripcslashes($author));
$zapr = mysql_query("UPDATE articles SET author='$author', theme='$theme', article='$article' WHERE id_a='$id_a';");
print "<html><head>\n";
print "<meta http-equiv='refresh' content='0; url=aarticles.php'>\n";
print "</head></html>\n";
}
?>
</body>
</html>
Если жестко в самом начале скрипта (после include "../condb.php") забиваю значение переменной id_a = 1; то скрипт работает нормально. Почему без этого не работает? Ведь первый запрос нормально работает!
Тогда в condb.php пропиши $id_a=$_GET['id_a'];
Цитата:
Originally posted by civ3
Так откуда это $id_a берется? Из GET'a?
Тогда в condb.php пропиши $id_a=$_GET['id_a'];
Так откуда это $id_a берется? Из GET'a?
Тогда в condb.php пропиши $id_a=$_GET['id_a'];
Не.. Так тоже пробовал! Не работает! Кстати, condb - это только скрипт для подключения к бд. А id_a передается вот так
Код:
echo "<th><a href=editor.php?id_a=".$shart['id_a'].">редактировать</a></th>";
Все! Нашел ошибку. У меня в скрипте параметр id просто не передавался =(