Bman900 Posted May 5, 2009 Share Posted May 5, 2009 Here is my code: mysql_connect("$dbhost", "$dbusername", "$dbpassword") or die(mysql_error()); mysql_select_db("$databasename") or die(mysql_error()); $newtitlecolor = $_POST['titlecolor']; $newheadercolor = $_POST['headercolor']; $newheaderlink = $_POST['headerlinks']; $newnavcolor = $_POST['navbackround']; $newnavigationlink = $_POST['navlinks']; $newleftsidecolor = $_POST['leftside']; $newfootercolor = $_POST['footercolor']; $newfootertext = $_POST['footertext']; mysql_query("UPDATE style_options SET styleinput='$newheadercolor' WHERE styleinput='$headercolor' AND id = '1'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newnavcolor' WHERE styleinput='$navcolor' AND id = '2'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newleftsidecolor' WHERE styleinput='$leftsidecolor' AND id = '3'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newfootercolor' WHERE styleinput='$footercolor' AND id = '4'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newheaderlink' WHERE styleinput='$headerlink' AND id = '5'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newnavigationlink' WHERE styleinput='$navigationlink' AND id = '6'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newfootertext' WHERE styleinput='$footertext' AND id = '7'") or die(mysql_error()); mysql_query("UPDATE style_options SET styleinput='$newtitlecolor' WHERE styleinput='$titlecolor' AND id = '8'") or die(mysql_error()); echo "Update succesfull!<br />"; echo "<center>[<a href=\"editstyle.php\">Go BACK</a>]</center>"; The Update successful message comes trough but nothing really gets updated. Whats wrong here? Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/ Share on other sites More sharing options...
ohdang888 Posted May 5, 2009 Share Posted May 5, 2009 two things... 1) put tags around your php code in the code. it helps us. 2) do a print_r($_POST) to see if the post variables are set. Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826963 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Yes, please use proper formatting. Read #4 under Forum DO's - http://www.phpfreaks.com/page/rules-and-terms-of-service#toc_forum_dos Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826965 Share on other sites More sharing options...
Bman900 Posted May 5, 2009 Author Share Posted May 5, 2009 Sorry about that, I will do it like that next time. I went back and did what you told me and got: Array ( [titlecolor] => #00FF00 [headercolor] => #00FF00 [headerlinks] => #00FF00 [navbackround] => #00FF00 [navlinks] => #00FF00 [leftside] => #00FF00 [footercolor] => #00FF00 [footertext] => #00FF00 [sumbit] => Submit ) It looks like the error is with the update code, but everything matches up and it should give me an error if it doesnt. Any guesses? Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826974 Share on other sites More sharing options...
Bman900 Posted May 5, 2009 Author Share Posted May 5, 2009 I found it, I never included my variables for the original values. Wow am getting old or something... Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826979 Share on other sites More sharing options...
revraz Posted May 5, 2009 Share Posted May 5, 2009 Where do you set your WHERE variables? Like $headercolor Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826980 Share on other sites More sharing options...
revraz Posted May 5, 2009 Share Posted May 5, 2009 Easy way to find these errors is to echo your query out, that way you will see the missing variables. I found it, I never included my variables for the original values. Wow am getting old or something... Link to comment https://forums.phpfreaks.com/topic/156987-not-updating-right/#findComment-826983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.