Page 1 of 1

PHP updates the table, but the database table is still empty

Posted: Sun Nov 03, 2002 11:16 am
by Skywalker
I have a table that as a new colum named blok

table looks like this

ID - Name - BackName - etc - Blok

The colum of blok is empty and ther is nothing in, at the beginning until the table must be updated by a klick on a link, the table must be updated and ther must be inserted THE WORD YES in to the Blok Colum


The sorce works just fine only the database is still not updated after php sorce has runed. Can somebody what went wrong and what i have to change?



<?php require_once('Connections/Verbinding.php'); ?>

<?php
$ID = $_POST['ID'];
$Naam = $_POST['Naam'];
$AchterNM = $_POST['AchterNM'];
$WNPlaats = $_POST['WNplaats'];
$Post = $_POST['Post'];
$Straat = $_POST['Straat'];
$Studie = $_POST['Studie'];
$Email = $_POST['Email'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Blok = $_POST['Blok'];
$Table = $_POST['Table'];

$Host = "localhost";
$Gebruiker = "blabla";
$Wachtwoord = "blabla";
$DBNaam = "blabla";

$Connectie = mysql_connect ($Host, $Gebruiker, $Wachtwoord);

$Opdracht = "Update $Table SET ID=$ID, Naam=$Naam, AchterNM=$AchterNM, WNPlaats=$WNPlaats, Post=$Post, Straat=$Straat, Studie=$Studie, Email=$Email, Username=$Username, Password=$Password, Blok='yes'";
$Result = mysql_db_query ($DBNaam, $Opdracht, $Connectie);
echo ("<font face=\"verdana\" size=\"2\"><b>Gebruiker wordt geblokeerd een ongenblik geduld AUB</b> <META HTTP-EQUIV=\"refresh\" content=\"8;URL=admin.php\"><br>\n");

?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#CCCCFF">
</body>
</html>

update sintax

Posted: Sun Nov 03, 2002 11:42 am
by AVATAr
if you need to use update, the sintax is:

UPDATE table_name
SET col_name = expre1...
WHERE ID = $ID

you are not using the WHERE so mysql can find the row.
The WHERE clause, if given, specifies which rows should be updated. Otherwise, all rows are updated.