[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: mysql_query "UPDATE" не обновляет записи
msvanciu
Всем привет, в php я не очень разбираюсь, я только учусь, да и при этом у меня выбора нету.
Делаю дипломную работу, к четвергу уже должен сдать а у меня ошибок куча, ладно все больше не ною. (скажу сразу все это я делал по курсу Попова и почему то у него работает а у меня нет)

В общем у меня такая проблема, при редактировании записей когда я жму обновить у меня пишет Ваш урок успешно обновлён! но в базу никаких изменений не происходят, да и ошибок в коде вроде нету.

Вот код файла edit_reg_nord.php

<?php include ("blocks/bd.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Ad&#259;ugarea unei noi mănăstiri</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
meta name="robots" content="all" />
<
meta name="Googlebot" content="index" />
<
meta property="og:site_name" content="manastirile-moldovei.com" />
<
meta property="og:title" content="Manastiri ortodoxe din Republica Moldova" />
<
meta property="og:image" content="" /><meta property="og:url" content="http://www.manastirile-moldovei.com" />
<
meta property="og:description" content="Asezamintele monahale au fost de-a lungul timpului adevarate fortarete, cetati de eroism si centre de cultura, cum ar fi Manastirea Capriana, Noul Neamt - Manastirile sunt ctitorite in locuri pitoresti"/>
<
link rel="canonical" href="http://manastirile-moldovei.com" />
<
link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<
link rel="stylesheet" href="style.css" type="text/css" />
<
script type="text/javascript" src="../script.js"></script>
<
link rel="stylesheet" type="text/css" href="style/style.css" />
<
script type="text/javascript" src="js/script.js"></script>
</
head>
<
body>
<
table align="center" border="1" cellpadding="0" cellspacing="5" height="100%" width="1004" bordercolor="#FAA819">
<? include("blocks/header.php"); ?>
<?
include("blocks/menu.php"); ?>
<tr>
<? include("blocks/sidebar-left.php" ); ?>
<td width="564" height="200" valign="top">


<?php
if (!isset($_GET['id']))
{
$result = mysql_query("SELECT title,id FROM reg_nord");
$myrow = mysql_fetch_array($result);
do
{
printf ("<p><a href = 'edit_reg_nord.php?id=%s'>%s</a></p>",$myrow["id"],$myrow["title"]);
}
while ($myrow = mysql_fetch_array($result));
}

else

{
$result = mysql_query("SELECT * FROM reg_nord WHERE id=$_GET[id]");
$myrow = mysql_fetch_array ($result);

echo "<form id='form1' name='form1' method='post' action='update_reg_nord.php'>";

print <<<HERE
<p>
<label for="title">Имя</label>
<br />
<input value="
$myrow[title]" type="text" name="title" id="title" />
</p>
<p>
<label for="img">Фотка</label>
<textarea name="img" id="img" cols="50" rows="2">
$myrow[img]</textarea>
</p>
<p>
<label for="meta_d">Краткое описание</label>
<br />
<input value="
$myrow[meta_d]" type="text" name="meta_d" id="meta_d" size="64" />
</p>

<p>
<label for="meta_k">Ключевые слова</label>
<br />
<input value="
$myrow[meta_k]" type="text" name="meta_k" id="meta_k" size="64" />
</p>
<p>
<label for="date">Дата<br />
</label>
<input value="
$myrow[date]" name="date" type="date" id="date" value="" />
</p>
<p>
<label for="description">Краткое описание</label></br>
<textarea name="description" id="description" cols="50" rows="5">
$myrow[description]</textarea>
</p>
<p>
<label for="text">Полное описание</label>
<textarea name="text" id="text" cols="50" rows="20">
$myrow[text]</textarea>
</p>
<p>
<label for="author">Автор</label>
<br />
<input value="
$myrow[author]" type="text" name="author" id="author" />
</p>
<input name="id" type="hidden" value="
$myrow[id]">

<p>
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Обновить" />
</p>
<p><br />
</p>
</form>

HERE;
}
?>

</td>
<? include("blocks/sidebar-right.php" ); ?>
</tr>
<? include ("blocks/author.php"); ?>
<?
include ("blocks/footer.php")?>
</table>
</
body>
</
html>


И вот его обработчик

<?php
include('blocks/bd.php');
if (isset ($_POST['title'])) {$title=$_POST['title']; if($title =='') {unset ($title);}}
if (isset ($_POST['img'])) {$img = $_POST['img']; if($img =='') {unset ($img);}}
if (isset ($_POST['meta_d'])) {$meta_d = $_POST['meta_d']; if($meta_d =='') {unset ($meta_d);}}
if (isset ($_POST['meta_k'])) {$meta_k=$_POST['meta_k']; if($meta_k =='') {unset ($meta_k);}}
if (isset ($_POST['date'])) {$date=$_POST['date']; if($date =='') {unset ($date);}}
if (isset ($_POST['description'])) {$description = $_POST['description']; if($description =='') {unset ($description);}}
if (isset ($_POST['text'])) {$text = $_POST['text']; if($text =='') {unset ($text);}}
if (isset ($_POST['author'])) {$author = $_POST['author']; if($author =='') {unset ($author);}}
if (isset ($_POST['id'])) {$id = $_POST['id'];}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Modificarea unei m&#259;năstiri</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
meta name="robots" content="all" />
<
meta name="Googlebot" content="index" />
<
meta property="og:site_name" content="manastirile-moldovei.com" />
<
meta property="og:title" content="Manastiri ortodoxe din Republica Moldova" />
<
meta property="og:image" content="" /><meta property="og:url" content="http://www.manastirile-moldovei.com" />
<
meta property="og:description" content="Asezamintele monahale au fost de-a lungul timpului adevarate fortarete, cetati de eroism si centre de cultura, cum ar fi Manastirea Capriana, Noul Neamt - Manastirile sunt ctitorite in locuri pitoresti"/>
<
link rel="canonical" href="http://manastirile-moldovei.com" />
<
link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<
link rel="stylesheet" href="style.css" type="text/css" />
<
script type="text/javascript" src="../script.js"></script>
<
link rel="stylesheet" type="text/css" href="style/style.css" />
<
script type="text/javascript" src="js/script.js"></script>
</
head>
<
body>
<
table align="center" border="1" cellpadding="0" cellspacing="5" height="100%" width="1004" bordercolor="#FAA819">
<? include("blocks/header.php"); ?>
<?
include("blocks/menu.php"); ?>
<tr>
<? include("blocks/sidebar-left.php" ); ?>
<td width="564" height="200" valign="top">

<?php if (isset($title) && isset($img) && isset($meta_d) && isset($meta_k) && isset($date) && isset($description) && isset($text) && isset($author))
{

$result = mysql_query ("UPDATE `reg_nord` SET `title`='$title',`img`='$img', `meta_d`='$meta_d', `meta_k`='$meta_k',`date`='$date', `description`='$description', `text`='$text', `author`='$author' WHERE `id`='id'");


if ( $result == true ) {
echo "<p>Ваш урок успешно обновлённ!</p>";
}
else {echo "<p>Ваш урок не обновлён!</p>";}
}


else

{
echo "<p>Заполните все поля!</p>";
}

?> <p> </p></td>
<? include("blocks/sidebar-right.php" ); ?>
</tr>
<? include ("blocks/author.php"); ?>
<?
include ("blocks/footer.php")?>
</table>
</
body>
</
html>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2025 Invision Power Services, Inc.