Clinton Posted April 16, 2008 Share Posted April 16, 2008 Not Updating... Not sure why... <? $id = $_GET["id"]; $facpr = $_GET["facpr"]; ?> <?php $username = "*****"; $password = "*****"; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to Server<br>"; $selected = mysql_select_db("*****",$dbhandle) or die("Can not open SLC Database"); echo "Connected to Salt Lake City Database<p>"; mysql_query("UPDATE training SET firstaidcpr = '$facpr' WHERE id='$id'"); echo "Database has been updated. You will be returned to the training page momentarily. <meta http-equiv='refresh' content='3;URL=training.php' >" ?> <html> <head> <title>Database is Updating...</title> </head> <body bgcolor="#FFFFFF"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/ Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 change $selected = mysql_select_db("*****",$dbhandle) or die("Can not open SLC Database"); echo "Connected to Salt Lake City Database<p>"; to: mysql_select_db("*****",$dbhandle) or die("Can not open SLC Database"); echo "Connected to Salt Lake City Database<p>"; Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518811 Share on other sites More sharing options...
Clinton Posted April 16, 2008 Author Share Posted April 16, 2008 Didn't do the trick. $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to Server<br>"; mysql_select_db("clintona_SLC",$dbhandle) or die("Can not open SLC Database"); echo "Connected to Salt Lake City Database<p>"; mysql_query("UPDATE training SET firstaidcpr = $facpr WHERE id=$id"); echo "Database has been updated. You will be returned to the training page momentarily. <meta http-equiv='refresh' content='3;URL=training.php' >" ?> <html> <head> <title>Database is Updating...</title> </head> <body bgcolor="#FFFFFF"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518817 Share on other sites More sharing options...
Clinton Posted April 16, 2008 Author Share Posted April 16, 2008 Now, I'm also trying to insert a date formatted 4/4/2007 into MySQL which is formatted 2007-04-04. Is that going to be a problem? Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518821 Share on other sites More sharing options...
benphp Posted April 16, 2008 Share Posted April 16, 2008 You need to reformat the date if your date field is a DATE type. $myDate = "4/4/2008"; list($smonth, $sday, $syear) = split('[/.-]', $myDate); $myDate = "$syear-$smonth-$sday"; then you can put it into your sql Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518823 Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 <html> <head> <title>Database is Updating...</title> </head> <?php $id = $_GET["id"]; $facpr = $_GET["facpr"]; ?> <body bgcolor="#FFFFFF"> <?php $username = "root"; $password = "*****"; //gotta love the fact I left the real password in there. glad it's just a test box. gotta change it now. $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password); echo "Connected to Server<br>"; mysql_select_db("testing",$dbhandle); echo "Connected to Salt Lake City Database<p>"; mysql_query("UPDATE training SET firstaidcpr = '$facpr' WHERE id='$id'"); echo "Database has been updated. You will be returned to the training page momentarily. <meta http-equiv='refresh' content='3;URL=training.php' >" ?> </body> </html> works great for me. I had it updating a test user just fine for me. Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518837 Share on other sites More sharing options...
Clinton Posted April 16, 2008 Author Share Posted April 16, 2008 Wow thanks. That will help out I'm sure. Question about that... when I do that I get the result 2007- 04-12 There is a space between the - and the 04 and my DB is still not updating. Anyway to get rid of that space? I was just trying to mess with the code but can's seem to figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518840 Share on other sites More sharing options...
Clinton Posted April 16, 2008 Author Share Posted April 16, 2008 Thanks JJ. It's got to be something with my whole date format then. Only thing I can think of. Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518843 Share on other sites More sharing options...
benphp Posted April 16, 2008 Share Posted April 16, 2008 Not sure why you'd be getting a space in there. But if you do, you can do this: $myDate = "4/4/2008"; list($smonth, $sday, $syear) = split('[/.-]', $myDate); $myDate = "$syear-$smonth-$sday"; $myDate = str_replace(" ", "", $myDate); Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518854 Share on other sites More sharing options...
Clinton Posted April 16, 2008 Author Share Posted April 16, 2008 That did it. It took out the space and now it works. Thanks a million. Quote Link to comment https://forums.phpfreaks.com/topic/101430-solved-not-updating/#findComment-518870 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.