Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blank page when postind to DB

    I have a set of 2 pages, one displays the details of a DB entry to be edited, the second posts the edited data to the DB. When I hit "submit", the second page is blank. These two pages are clones of two other pages that work fine. I have rechecked every line of code and can't find what makes the page go blank. I tried various lines of code to turn error reporting on to try to get a clue on what is happening but I don't get anyhting (my only choice with shared hosting).

    1) how can I get error reporting on and be sure it's working?
    2) can someone have a look at my code and maybe point to errors that I would have missed?

    Thank you.

    Here's the edit form code:

    Code:
    <?php
    // Obtenir la date et l'heure au moment du chargement de la page
    // pour pr&eacute;remplir les champs date_start et time_start
    $today = date("Ymd");
    $now = date("Hi");
    
    $item_id = $_GET['item_id'];
    
    
    $query_prev = "SELECT
    id AS item_id, title, theme, body, category, coverage, statut,
    DATE_FORMAT(date_start, '%Y%m%d') AS Fdate_start,
    DATE_FORMAT(date_end, '%Y%m%d') AS Fdate_end,
    TIME_FORMAT(date_start, '%H%i') AS Ftime_start,
    TIME_FORMAT(date_end, '%H%i') AS Ftime_end
    FROM moca_daysahead
    WHERE id = '$item_id'
    ";
    
    $result_prev = mysql_query($query_prev)
    or die ("Couldn't execute query <i>query_prev</i><br />".mysql_error().".");
    // echo "Query: ".$query_prev."<br /><br />";
    
    while ($row_prev = mysql_fetch_array($result_prev))
    {
    extract($row_prev);
    ?>
    
    <!-- START EDIT FORM -->
    <div class="tdborder1px">
    
    <form action="daysahead.php?daysahead_edited.php" method="post">
    <input type="text" name="item_id" size="50" value="<?php echo $item_id; ?>" hidden>
    <table border="0" cellspacing="2" cellpadding="4" width="100%">
    <tr>
    <td valign="middle" align="center" class="header_plus_brown">
    Pr&eacute;vision - &Eacute;dition
    </td>
    </tr>
    </table>
    
    
    <table border="0" cellspacing="2" cellpadding="4" width="100%">
    
    <tr bgcolor="#cccccc">
    <td valign="top" colspan="4">
    <b>Titre :</b>
    </td>
    </tr>
    
    <tr bgcolor="#eeeeee">
    <td valign="top" colspan="4">
    <?php
    echo "<input type=\"text\" name=\"title\" size=\"50\" value=\"$title\">";
    ?>
    </td>
    </tr>
    
    
    <tr bgcolor="#cccccc">
    <td valign="top" colspan="2">
    <b>Theme :</b>
    </td>
    
    <td valign="top" colspan="2">
    <b>Categorie :</b>
    </td>
    </tr>
    
    <tr bgcolor="#eeeeee">
    <td valign="top" colspan="2">
    <?php
    echo "<input type=\"text\" name=\"theme\" size=\"30\" value=\"$theme\">";
    ?>
    </td>
    
    <td valign="top" colspan="2">
    <?php
    echo "<input type=\"text\" name=\"category\" size=\"30\" value=\"$category\">";
    ?>
    </td>
    </tr>
    
    
    
    <tr bgcolor="#cccccc">
    <td valign="top" align="left">
    <b>Date d&eacute;but :</b> AAAAMMJJ
    </td>
    
    <td valign="top" align="left">
    <b>Heure d&eacute;but :</b> HHMM
    </td>
    
    <td valign="top" align="left">
    <b>Date fin :</b> AAAAMMJJ
    </td>
    
    <td valign="top" align="left">
    <b>Heure fin :</b> HHMM
    </td>
    </tr>
    
    
    <tr bgcolor="#eeeeee">
    <td valign="top" align="left">
    <?php
    echo "<input name=\"date_start\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"$Fdate_start\" />";
    ?>
    </td>
    
    <td valign="top" align="left">
    <?php
    echo "<input name=\"time_start\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"$Ftime_start\" />";
    ?>
    </td>
    
    <td valign="top" align="left">
    <?php
    echo "<input name=\"date_end\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"$date_end\" />";
    ?>
    </td>
    
    <td valign="top" align="left">
    <?php
    echo "<input name=\"time_end\" type=\"text\" size=\"4\" maxlength=\"4\" value=\"$time_end\" />";
    ?>
    </td>
    </tr>
    
    
    <tr bgcolor="#cccccc">
    <td valign="top" colspan="2">
    <b>Texte :</b><br /><textarea name="body" rows="10" cols="50"><?php echo $body; ?></textarea>
    </td>
    
    <td valign="top" colspan="2">
    <b>Couverture :</b><br /><textarea name="coverage" rows="10" cols="50"><?php echo $coverage; ?></textarea>
    </td>
    </tr>
    
    <tr>
    <td valign="top" colspan="2">
    <b>Priorit&eacute; :</b><br />
    <select name="priority">
    <?php
    if ($priority == '1')
    {
    echo "<option label=\"1\" value=\"1\" selected>1</option>";
    }
    else
    {
    echo "<option label=\"1\" value=\"1\">2</option>";
    }
    
    if ($priority == '2')
    {
    echo "<option label=\"2\" value=\"2\" selected>2</option>";
    }
    else
    {
    echo "<option label=\"2\" value=\"2\">2</option>";
    }
    
    if ($priority == '3')
    {
    echo "<option label=\"3\" value=\"3\" selected>3</option>";
    }
    else
    {
    echo "<option label=\"3\" value=\"3\">3</option>";
    }
    ?>
    </select>
    </td>
    
    
    <td valign="top" colspan="2">
    <b>Statut :</b><br />
    <?php
    if ($statut == '0')
    {
    echo "<img src=\"images/square_red.jpg\" alt=\"red\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"0\" checked> Brouillon<br />";
    }
    else
    {
    echo "<img src=\"images/square_white.jpg\" alt=\"white\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"0\"> Brouillon<br />";
    }
    
    if ($statut == '1')
    {
    echo "<img src=\"images/square_orange.jpg\" alt=\"orange\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"1\" checked> Validation<br />";
    }
    else
    {
    echo "<img src=\"images/square_white.jpg\" alt=\"white\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"1\"> Validation<br />";
    }
    
    if ($statut == '2')
    {
    echo "<img src=\"images/square_green.jpg\" alt=\"orange\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"2\" checked> Valid&eacute;<br />";
    }
    else
    {
    echo "<img src=\"images/square_white.jpg\" alt=\"white\" width=\"10\" height=\"10\" hspace=\"3\" vspace=\"3\" border=\"0\" align=\"left\" /> <input name=\"statut\" type=\"radio\" value=\"2\"> Valid&eacute;<br />";
    }
    ?>
    
    </td>
    </tr>
    
    <tr>
    <td bgcolor="#aaaaaa" valign="middle" colspan="4" align="center">
    <input type="submit" value="Go">
    </td>
    </tr>
    </table>
    </form>
    <!-- END EDIT FORM -->
    
    </div>
    <?php
    } // while
    ?>
    and here is the post to DB code:

    Code:
    <?php
    
    // GETTING FORM DATA
    $item_id= $_POST['item_id'];
    $date_modified = date("YmdHis");
    $date_start= $_POST['date_start'];
    $date_end= $_POST['date_end'];
    $time_start= $_POST['time_start'];
    $time_end= $_POST['time_end'];
    $title= $_POST['title'];
    $theme= $_POST['theme'];
    $body= $_POST['body'];
    $category= $_POST['category'];
    $coverage= $_POST['coverage'];
    $statut= $_POST['statut'];
    
    // CONVERTING HTML ENTITIES
    $title= htmlentities($title, ENT_QUOTES, "UTF-8");
    $theme= htmlentities($theme, ENT_QUOTES, "UTF-8");
    $body= htmlentities($body, ENT_QUOTES, "UTF-8");
    $category= htmlentities($category, ENT_QUOTES, "UTF-8");
    $coverage= htmlentities($coverage, ENT_QUOTES, "UTF-8");
    
    
    // INSERTING INTO DB
    $sql="
    UPDATE moca_daysahead
    SET
    date_modified = '$date_modified',
    date_start = '$date_start',
    date_end = '$date_end',
    time_start = '$time_start',
    time_end = '$time_end',
    title = '$title',
    theme = '$theme',
    body = '$body',
    category = '$category',
    coverage = '$coverage',
    statut = '$statut'
    WHERE id = '$item_id'
    ";
    // run SQL against the DB
    echo "<br />".$sql."<br />";
    $result = mysql_query($sql);
    /////////////////////////////
    
    ?>
    
    <p class="header_plus">
    Votre message a été &eacute;dit&eacute;.
    </p>
    
    <p class="header_plus">
    Merci.
    </p>

  • #2
    New Coder
    Join Date
    Dec 2005
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I solved my problem, so no need to reply, thank you. I had an error in my <form> syntax.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •