ciao,
se esiste $credit va alla pagina aaaa.php altrimenti elabora il resto del codice.
Mi da questo errore come mai?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3','0','FREE','Yes',NOW(),15,'','',,)' at line 2
ho inserito il codice correttamente tra le due parentesi graffe dopo else...
Codice PHP:
$creditsql = "select * from accounting where mid = ".$_SESSION['memberID'];
$creditR = mysql_query($creditsql,$myconn) or die(mysql_error());
$credit = mysql_fetch_assoc($creditR);
if ($credit){
header("Location: aaaa.php");
}
else {
$insert = "insert into accounting (`photoLimit`,`item`,`payment_gross`,`payment_status`,`active`,`payment_date`,`mid`,`title`,`description`,`days`,`numCredit`)
values (".$credit['photoLimit'].",'3','0','FREE','Yes',NOW(),".$_SESSION['memberID'].",'".$credit['title']."','".$credit['description']."',".$credit['days'].",".$credit['numCredit'].")";
//echo $insert;
mysql_query($insert,$myconn) or die(mysql_error());
$updateSQL = sprintf("UPDATE members SET `expires`=DATE_ADD(NOW(), INTERVAL ".$credit['days']." DAY) WHERE id=%s",
$_SESSION['memberID']);
mysql_query($updateSQL,$myconn) or die(mysql_error());
$insertGoTo = "a_index.php";
header(sprintf("Location: %s", $insertGoTo));
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}