affordit Posted February 13, 2008 Share Posted February 13, 2008 Can someone tell me why this is not updating <?php $reg = $_POST['registration']; include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select id, email, end_date FROM test WHERE `email`='$email'"; $result=mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)<1) { echo "You entered the wrong username or password or your email has already been verified."; } else { $end_date = date("Y-m-d",strtotime("$reg")); // // UPDATE THE ROW // $update = "UPDATE `test` SET `end_date`=$end_date WHERE `id`=" . $rows['id']; mysql_query($update); (header("location: index.php")); } ?> Link to comment https://forums.phpfreaks.com/topic/90929-help/ Share on other sites More sharing options...
rhodesa Posted February 13, 2008 Share Posted February 13, 2008 First, you never pull the row for the SELECT statement. Also, put the date in single quotes: <?php $reg = $_POST['registration']; include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select id, email, end_date FROM test WHERE `email`='$email'"; $result=mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)<1) { echo "You entered the wrong username or password or your email has already been verified."; } else { //Get Row $row = mysql_fetch_array($result); $end_date = date("Y-m-d",strtotime($reg)); // // UPDATE THE ROW // $update = "UPDATE `test` SET `end_date`='$end_date' WHERE `id`=" . $row['id']; mysql_query($update); (header("location: index.php")); } ?> Link to comment https://forums.phpfreaks.com/topic/90929-help/#findComment-466019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.