Jump to content

problems updating mysql


warptwist

Recommended Posts

I'm having a little trouble updating my DB.

 

Can anyone find the probem with this piece of code?

 

if ($password1 == $password2){
if ($password1 == 0000){
	mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn.", `fornavn` = '".$fornavn.", `efternavn` = '".$efternavn.", `adresse` = '".$adresse.", `nr` = '".$nr.", `postnr` = '".$postnr.", `by` = '".$by.", `tlf` = '".$tlf.", `mail` = '".$mail.", `holdnavn` = '".$holdnavn.", `kontakt` = '".$kontakt.", ' WHERE `id` = '".$id."'");
	echo "Oplysningerner er opdateret.";
} else {
	mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn.", `adgangskode` = MD5('".$password1."'), `fornavn` = '".$fornavn.", `efternavn` = '".$efternavn.", `adresse` = '".$adresse.", `nr` = '".$nr.", `postnr` = '".$postnr.", `by` = '".$by.", `tlf` = '".$tlf.", `mail` = '".$mail.", `holdnavn` = '".$holdnavn.", `kontakt` = '".$kontakt.", ' WHERE  `id` = '".$id."'");
	echo "Oplysningerner er opdateret.";
}
} else {
mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn.", `fornavn` = '".$fornavn.", `efternavn` = '".$efternavn.", `adresse` = '".$adresse.", `nr` = '".$nr.", `postnr` = '".$postnr.", `by` = '".$by.", `tlf` = '".$tlf.", `mail` = '".$mail.", `holdnavn` = '".$holdnavn.", `kontakt` = '".$kontakt.", ' WHERE  `id` = '".$id."'");
echo "Alle oplysninger er opdateret undtagen dit password, da dine indtastninger ikke stemte overens";
}

 

It echoes the correct line depending on the password given, but doesn't update the DB.

BTW I use includes to configure, and connect to my DB.

Link to comment
https://forums.phpfreaks.com/topic/132792-problems-updating-mysql/
Share on other sites

Thanks for the help. I didn't realize how much help the "or die" code was until now.

 

I found out that i had made numerous mistakes.

 

this is how the code works.

 

if ($password1 == $password2){
if ($password1 == 0000){
	mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn."', `fornavn` = '".$fornavn."', `efternavn` = '".$efternavn."', `adresse` = '".$adresse."', `nr` = '".$nr."', `postnr` = '".$postnr."', `by` = '".$by."', `tlf` = '".$tlf."', `mail` = '".$mail."', `holdnavn` = '".$holdnavn."', `kontakt` = '".$kontakt."' WHERE `id` = '".$id."'") or die(mysql_error());
	echo "Oplysningerner er opdateret.";
} else {
	mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn."', `adgangskode` = MD5('".$password1."'), `fornavn` = '".$fornavn."', `efternavn` = '".$efternavn."', `adresse` = '".$adresse."', `nr` = '".$nr."', `postnr` = '".$postnr."', `by` = '".$by."', `tlf` = '".$tlf."', `mail` = '".$mail."', `holdnavn` = '".$holdnavn."', `kontakt` = '".$kontakt."' WHERE `id` = '".$id."'") or die(mysql_error());
	echo "Oplysningerner er opdateret.";
}
} else {
mysql_query("UPDATE `aabsupportbrugere` SET `brugernavn` = '".$brugernavn."', `fornavn` = '".$fornavn."', `efternavn` = '".$efternavn."', `adresse` = '".$adresse."', `nr` = '".$nr."', `postnr` = '".$postnr."', `by` = '".$by."', `tlf` = '".$tlf."', `mail` = '".$mail."', `holdnavn` = '".$holdnavn."', `kontakt` = '".$kontakt."' WHERE `id` = '".$id."'") or die(mysql_error());
echo "Alle oplysninger er opdateret undtagen dit password, da dine indtastninger ikke stemte overens";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.