Dmitriko

Статус
  • Активный

Последние сообщения Dmitriko

  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 16:52

    исправил id на nameArray(    [title] => ytfhd    [date] => 0000-00-00    [keywords] => dfgdf    [description] => gdgd    [annotations] => fgdfgdfg    [content] => gdfgdfg    [id] => 12    [submit] => Оновити лекцію )Ви не заповнили всі поля. Лекція не була обновленапо попр...
    исправил id на name

    Array
    (
       [title] => ytfhd
       [date] => 0000-00-00
       [keywords] => dfgdf
       [description] => gdgd
       [annotations] => fgdfgdfg
       [content] => gdfgdfg
       [id] => 12
       [submit] => Оновити лекцію
    )
    Ви не заповнили всі поля. Лекція не була обновлена


    по попрежнему не мохраняет лекцию.

    Дальше то реально должна встать на проверке true.

    а что тут нужно править ?

  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 16:43

  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 16:21

    if($_POST['title'] != '')изменил в своем коде.вставил в код этоprint '<pre>';print_r($_POST);print '</pre>;получилArray( [id] => 12 [submit] => Оновити лекцію )Ви не заповнили всі поля. Лекція не була обновленапочему 'true' — строка?так...
    if($_POST['title'] != '')

    изменил в своем коде.

    вставил в код это


    print '<pre>';
    print_r($_POST);
    print '</pre>;


    получил

    Array
    (
    [id] => 12
    [submit] => Оновити лекцію
    )
    Ви не заповнили всі поля. Лекція не була обновлена


    почему 'true' — строка?

    так в лабе написано.
  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 15:24

    код файла update_lection.php<?phpinclude ("connectdb.php");if (isset($_POST['title'])) {$title = $_POST['title']; if ($title == '') {unset($title);}}if (isset($_POST['annotations'])) {$annotations = $_POST['annotations']; if ($annotations == &#...
    код файла update_lection.php
    <?php
    include ("connectdb.php");
    if (isset($_POST['title'])) {$title = $_POST['title']; if ($title == '') {unset($title);}}
    if (isset($_POST['annotations'])) {$annotations = $_POST['annotations']; if ($annotations == '') {unset($annotations);}}
    if (isset($_POST['author'])) {$author = $_POST['author']; if ($author == '') {unset($author);}}
    if (isset($_POST['content'])) {$content = $_POST['content']; if ($content == '') {unset($content);}}
    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['keywords'])) {$keywords = $_POST['keywords']; if ($keywords == '') {unset($keywords);}}
    if (isset($_POST['id'])) {$id = $_POST['id'];}
    ?>
    <head>
    <title>Опрацьовувач форми</title>
    </head>
    <body>

    <table border="1" align="center" class="main_border">
    <?php include ("header.php");?>
    <?php include ("navigation.php");?>
    <td width="458" bgcolor="#FFFFFF" valign="top">
    <?php
    if (isset($title) && isset($annotations) && isset($author) && isset($content) && isset($date) && isset($description) && isset($keywords))
    {

    $res = mysql_query ("UPDATE lections SET
    id='$id',
    title='$title',description='$description',keywords='$keywords',
    date='$date',annotations='$annotations',content='$content',author='$author'
    WHERE id='$id'");
    print $res;
    if ($res == 'true') {echo "<p>Ваша лекція успішно обновлена</p>";}
    else {echo "<p>Ваша лекція не одновлена</p>";}
    }
    else {echo "<p>Ви не заповнили всі поля. Лекція не була обновлена</p>";}
    ?>
    </td>
    </tr>
    <?php include ("footer.php");
    ?>
    </table>
    </body>
    </html>


    код файла edit_lection.php

    <?php include ("connectdb.php");
    if (isset($_GET['id'])) {$id = $_GET['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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Редагувати лекцію</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table border="1" align="center" class="main_border">
    <?php include ("header.php");?>
    <?php include ("navigation.php");?>
    <td width="458" bgcolor="#FFFFFF" valign="top">
    <?php
    if (!isset ($id))
    {
    $res = mysql_query ("SELECT title, id FROM lections");
    $connection = mysql_fetch_array($res);
    do
    {
    printf("<p><a href = 'edit_lection.php?id=%s'>%s</a></p>", $connection ["id"], $connection ["title"]);
    }
    while ($connection = mysql_fetch_array($res));
    }
    else
    {
    $ress = mysql_query ("SELECT * FROM lections WHERE id=$id");
    $con= mysql_fetch_array($ress);
    print <<<HERE

    <form action="update_lection.php" method="post" name="form1" id="form1" >
    <p><span class="lections_title">Введіть назву лекції:</span><br />
    <input value={$con['title']} type="text" id="title" maxlength="80" />
    <p><span class="lections_title">Вкажіть автора лекції:</span><br />
    <input value={$con['author']} type="text" id="author" maxlength="80" />
    <p><span class="lections_title">Вкажіть дату додавання лекції:</span><br />
    <input value={$con['date']} type="text" id="date" maxlength="80" />
    <p><span class="lections_title">Вкажіть ключові слова:</span><br />
    <input value={$con['keywords']} type="text" id="keywords" maxlength="80" />
    <p><span class="lections_title">Вкажіть опис лекції для пошукових систем:</span><br />
    <input value={$con['description']} type="text" id="description" maxlength="80" />
    <p><span class="lections_title">Введіть короткий опис лекції:</span><br />
    <textarea value="annotations" type="text" rows="10" id="annotations" style="margin: 2px; width: 467px; height: 160px;">{$con['annotations']}</textarea>
    <p><strong></br>Введіть матеріал лекції:</span><br />
    <textarea value="content" type="text" rows="10" id="content" style="margin: 2px; width: 467px; height: 250px;">{$con['content']}</textarea>
    <input name="id" type="hidden" value={$con['id']} />
    <input name="submit" type="submit" id="submit" value="Оновити лекцію " />
    <br />
    </label>
    </form>

    HERE;

    }
    ini_set('display_errors',1);
    error_reporting(E_ALL);
    ?>
    </td>
    </tr>
    <?php include ("footer.php");?>
    </table>
    </body>
    </html>


    поправил так как Вы казали, но по прежнему при сохранении отредактированой лекции я вижу надпись
    Ви не заповнили всі поля. Лекція не була обновлена
  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 14:20

    лабораторка? да. она самаяЯ-то думал про существование register_globals все уже забыли. Выключите их обратно и тоже забудьте, тем более что вы их не используете.Выключил.$connection = mysql_fetch_array($res);<?php include ("footer.php");?></table></body></html>а ...
    лабораторка?

    да. она самая

    Я-то думал про существование register_globals все уже забыли. Выключите их обратно и тоже забудьте, тем более что вы их не используете.

    Выключил.

    $connection = mysql_fetch_array($res);

    <?php include ("footer.php");?>
    </table>
    </body>
    </html>

    а что тут не так ?

    Если выводить элемент массива внутри строки, его нужно оборачивать в {}.
    + ключ элемента — это строка, она в кавычках должна быть.
    В редакторе нет подстветки синтаксиса?

    можете навести пример ?

  • PHP для идиотовОтправка переменных с конструкции <<<HERE • 17 декабря 2012 г. 6:12

    Всем доброй ночи. Собственно вот в чем проблема.Есть файл с формой редактирования материала. При редактировании данные корректно подгружаются в нужные поля. Но когда пытаюсь сохранить файл то постоянно форма отдает пустые значения. код формы.<?php include ("connectdb.php");if (isse...
    Всем доброй ночи. Собственно вот в чем проблема.
    Есть файл с формой редактирования материала. При редактировании данные корректно подгружаются в нужные поля. Но когда пытаюсь сохранить файл то постоянно форма отдает пустые значения.

    код формы.


    <?php include ("connectdb.php");
    if (isset($_GET['id'])) {$id = $_GET['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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Редагувати лекцію</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table border="1" align="center" class="main_border">
    <?php include ("header.php");?>
    <?php include ("navigation.php");?>
    <td width="458" bgcolor="#FFFFFF" valign="top">
    <?php
    if (!isset ($id))
    {
    $res = mysql_query ("SELECT title, id FROM lections");
    $connection = mysql_fetch_array($res);
    do
    {
    printf("<p><a href = 'edit_lection.php?id=%s'>%s</a></p>", $connection ["id"], $connection ["title"]);
    }
    while ($connection = mysql_fetch_array($res));
    }
    else
    {
    $ress = mysql_query ("SELECT * FROM lections WHERE id=$id");
    $con= mysql_fetch_array($ress);
    print_r($con);
    print <<<HERE
    <form action="update_lection.php" method="post" name="form1" id="form1" >
    <p><span class="lections_title">Введіть назву лекції:</span><br />
    <input value="$con[title]" type="text" id="title" maxlength="80" />
    <p><span class="lections_title">Вкажіть автора лекції:</span><br />
    <input value="$con[author]" type="text" id="author" maxlength="80" />
    <p><span class="lections_title">Вкажіть дату додавання лекції:</span><br />
    <input value="$con[date]" type="text" id="date" maxlength="80" />
    <p><span class="lections_title">Вкажіть ключові слова:</span><br />
    <input value="$con[keywords]" type="text" id="keywords" maxlength="80" />
    <p><span class="lections_title">Вкажіть опис лекції для пошукових систем:</span><br />
    <input value="$con[description]" type="text" id="description" maxlength="80" />
    <p><span class="lections_title">Введіть короткий опис лекції:</span><br />
    <textarea value="annotations" type="text" rows="10" id="annotations" style="margin: 2px; width: 467px; height: 160px;">$con[annotations]</textarea>
    <p><strong></br>Введіть матеріал лекції:</span><br />
    <textarea value="content" type="text" rows="10" id="content" style="margin: 2px; width: 467px; height: 250px;">$con[content]</textarea>
    <input name="id" type="hidden" value="$con[id]" />
    <input name="submit" type="submit" id="submit" value="Оновити лекцію " />
    <br />
    </label>
    </form>
    HERE;
    }
    ?>
    </td>
    </tr>
    <?php include ("footer.php");?>
    </table>
    </body>
    </html>


    код обработчика.


    <?php
    include ("connectdb.php");
    if (isset($_POST['title'])) {$title = $_POST['title']; if ($title == '') {unset($title);}}
    if (isset($_POST['annotations'])) {$annotations = $_POST['annotations']; if ($annotations == '') {unset($annotations);}}
    if (isset($_POST['author'])) {$author = $_POST['author']; if ($author == '') {unset($author);}}
    if (isset($_POST['content'])) {$content = $_POST['content']; if ($content == '') {unset($content);}}
    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['keywords'])) {$keywords = $_POST['keywords']; if ($keywords == '') {unset($keywords);}}
    if (isset($_POST['id'])) {$id = $_POST['id'];}
    ?>
    <head>
    <title>Опрацьовувач форми</title>
    </head>
    <body>
    <table border="1" align="center" class="main_border">
    <?php include ("header.php");?>
    <?php include ("navigation.php");?>
    <td width="458" bgcolor="#FFFFFF" valign="top">
    <?php
    if (isset($title) && isset($annotations) && isset($author) && isset($content) && isset($date) && isset($description) && isset($keywords))
    {
    $res = mysql_query ("UPDATE lections SET
    id='$id',
    title='$title',description='$description',keywords='$keywords',
    date='$date',annotations='$annotations',content='$content',author='$author'
    WHERE id='$id'");
    print $res;
    if ($res == 'true') {echo "<p>Ваша лекція успішно обновлена</p>";}
    else {echo "<p>Ваша лекція не одновлена</p>";}
    }
    else {echo "<p>Ви не заповнили всі поля. Лекція не була обновлена</p>";}
    ?>
    </td>
    </tr>
    <?php include ("footer.php");
    ?>
    </table>
    </body>
    </html>


    register_globals=on
    В чем может быть проблема ?