Sounds a bit stoopid :? But can somebody help me fast?

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

Sounds a bit stoopid :? But can somebody help me fast?

Post by Skywalker »

My syntax is this, but it still doesn't update the empty table colum

$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=$Blok, WHERE ID=$ID";
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You probably need single quotes around all of those strings that you are trying to enter and no comma before the WHERE clause:

Code: Select all

$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='$Blok' WHERE ID='$ID'";
Mac
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

It still doesn't work Don't forget that the Blok Table Colum is empty in the first place.

As you can see herehttp://members.chello.nl/~s.vandemeulen/test.jpg
Kyori
Forum Newbie
Posts: 23
Joined: Mon Oct 14, 2002 5:23 am
Contact:

Post by Kyori »

i'm not sure if i understand you but here goes...

you cannot update an empty table.

remove comma before WHERE

If there a $id value in your table?


Other than that, I just learned a thing from you. That's a very short way of doing things. I would have done it this way.

'UPDATE tablename SET id=' . $id . ', naam=' . $naam . ' WHERE id=' . $id;
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried echoing out the query to make sure that all the variables are being passed to it correctly? Have you tried running the query in phpMyAdmin? (Obviously replacing the variables, $ID, $blok etc with actual data). You are putting the statement through a mysql_query() call aren't you?

Code: Select all

mysql_query($Opdracht) or die(mysql_error().'<p>'.$Opdracht.'</p>');
Mac
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

Yes that is correct first it makes a query on the page and on that page ther is a link that must be able to send al the qeury information of just one row with an uniec number (ID)

To Blockuser.php and in that source coed stands that The row with this ID has to be updated The update must be don in the colm BLOK in to ther has to come the word YES So that the blok colm is not enymore empty and contains the word yes

So the user has still his account, but it contains the word yes in blok and when Blok is Yes, the user can not continue with login because he is blocked.

Maybe that is more clear. But maybe I should fill in for al the Blok Colms A NO in the first place so I can update it to a YES?

Maybe that will work? What do you guys think?

Greathings Skywalker
smesquita
Forum Newbie
Posts: 7
Joined: Wed Oct 23, 2002 5:53 am

Post by smesquita »

The colum can be empty. If you want to update just one colum you may do this:

Code: Select all

$Opdracht = "Update $Table SET Blok='$Blok' WHERE ID=$ID";
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What type of column is blok? varchar? And smesquita is right, if you only want to update one column you don't have to put in the information for all the others as well.

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

Post by Skywalker »

that's right, the clom is Char and I will try the easy way then :D
Post Reply