Jump to content

Help


affordit

Recommended Posts

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

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

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.