100 Web Space
http://forum.100webspace.com/

Update problem
http://forum.100webspace.com/viewtopic.php?f=5&t=4734
Page 1 of 1

Author:  gfournier [ Fri Aug 18, 2006 4:46 am ]
Post subject:  Update problem

The problem is when I want to update a date field.

I've created a database and when I Insert data, I have no problem. But when it comes to updating date fields, it doesn't work. The date always reset to the default (0000-00-00). I don't understand why because the format of the updated date is correct (eg 2006-01-01).

here's my code

Quote:
<?php
include("connection.php");

$resultats = mysql_query("SELECT ID,Titre,Date,Auteur,Email,Texte FROM nouvelle WHERE ID=$_GET[id]");
while ($row = mysql_fetch_array($resultats))
{
?>

<html>
<head>
<title>formulaire</title>
<head>
<body>
Pour modifier :<br>
<form method="post" action="update_nouvelles.php">
Titre : <input type="text" name="titre" value="<?php echo $row['Titre']?>"><br>
Date: <input type="text" name="date" value="<?php echo $row['Date']?>"><br>
Auteur : <input type="text" name="auteur" value="<?php echo $row['Auteur']?>"><br>
Email : <input type="text" name="email" value="<?php echo $row['Email']?>"><br>
Texte : <Textarea name="texte"><?php echo $row['Texte']?></textarea>
<input type="hidden" name="id" value="<?php echo $row['ID']?>"><br>
<input type="submit" name="submit" value="Valider">
</form>
</body>
</html>

<?php
}

include("disconnection.php");
?>


Quote:
<?php
include("connection.php");


mysql_query("UPDATE nouvelle SET Titre=$titre, Date=$date, Auteur=$auteur, Email=$email, Texte=$texte WHERE ID=$id");

echo "Les modifications ont été apportées avec succès.<br><br>";
echo "Titre: " . $titre . "<br>";
echo "Date: " . $date . "<br>";
echo "Auteur: " . $auteur . "<br>";
echo "Email: " . $email . "<br>";
echo "Texte: " . $texte . "<br>";

include("disconnection.php");
?>

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/