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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

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

Post 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>
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

update sintax

Post 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.
Post Reply