This topic is locked

Inserting a date

10/29/2009 8:05:49 AM
PHPRunner General questions
R
ragrim author

im updating a 2nd table with an after add event and it seems to work but its not entering the correct date, instead its entering 0000-00-00
here is the code im using

$subexpires = $values["Expires"];

$subnum = $values["FKSubNum"];
global $conn;

$strSQLInsert = "UPDATE userinfo

INNER

JOIN subscribernumbers

ON subscribernumbers.FKUserID = userinfo.User_ID

SET userinfo.SubExpires = $subexpires

WHERE subscribernumbers.SubNumber = $subnum";

db_exec($strSQLInsert,$conn)


Im displaying dates in DD-MM-YYYY format and mysql saves them in YYYY-MM-DD, is it possible i need to reformat my date before inserting it?

J
Jane 10/29/2009

Hi,
please see my changes below:

$subexpires = date("Y-m-d",strtotime($values["Expires"]));
F
francoantonacci 10/29/2009

I have some problem, i am updating a 2nd table with an after add event and it seems to work but its not entering the correct date, instead its entering 0000-00-00, but the format date is correct, i'm displaying dates in YYYY-MM-DD
my code:
// Parameters:

// $values - Array object.

// Each field on the Add form is represented as a 'Field name'-'Field value' pair

// $keys - Array object with added record key column values
//** Insert a record into another table ****

global $conn;

$fechacuota = date("Y-m-d",strtotime($values["fecha_inicio_credito"]));

$saldo = $values["monto_autorizado"];

$fin = $values["cantidad_cuotas"];

$tiempogracia = $values["tiempo_gracia"];

$numerocuota = 0;

$cedula = $values["cedula_credito"];

$interesordinario = ($values["interes_ordinario"] / 100) (30 / 360);

echo $fechacuota;

$base = (1 + $interesordinario);

$exponente = -($fin - $tiempogracia);

$resultado = pow($base, $exponente);

$cuotafija = ($values["monto_autorizado"])
(($interesordinario) / (1 - $resultado));

$numerocredito = $values["nro_credito"];

for ($i = 1; $i <= $fin; $i++) {

$numerocuota++;

$columnainteres = ($saldo * $interesordinario);

$amortizacion = $cuotafija - $columnainteres;

$saldo = $saldo - $amortizacion;

$strSQLInsert = "insert into cuotas (cedula_cuota, nro_credito_cuota, nro_cuota, fecha_cuota, interes, amortizacion, cuota_fija, saldo) values ($cedula, $numerocredito, $numerocuota, $fechacuota, $columnainteres, $amortizacion, $cuotafija, $saldo)";

db_exec($strSQLInsert,$conn);

} // fin del ciclo for
//** Display a message on the Web page ****

echo "TABLA DE AMORTIZACION GENERADA .....";

J
Jane 10/30/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.