Jump to content

Mysql Tarih Yazdıramıyorum ?


Recommended Posts

arkdaşlar kod şöyle hatalı yeri işaretledim.

<?php require_once('../Connections/asd.php'); ?>
<?php
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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
/*/////////////////////////////////////////////////////////////////////////////////////////////
//burası
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $tarih = $_POST['yil'] ."-". $_POST['ay'] . "-" . $_POST['gun'];
  $insertSQL = sprintf("INSERT INTO ytarihi (tarih_ogradsoyad, mat) VALUES (%s, $tarih)",
                       GetSQLValueString($_POST['tarih_ogradisoyadi'], "text"));

  mysql_select_db($database_asd, $asd);
  $Result1 = mysql_query($insertSQL, $asd) or die(mysql_error());

}
//////////////////////////////////////////////////////////////////////////////////////////////*/
mysql_select_db($database_asd, $asd);
$query_Recordset1 = "SELECT ogradi, ogrsoyadi FROM ogr ORDER BY ogradi ASC";
$Recordset1 = mysql_query($query_Recordset1, $asd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_asd, $asd);
$query_Recordset2 = "SELECT mat FROM ytarihi";
$Recordset2 = mysql_query($query_Recordset2, $asd) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  <table width="100%" border="1">
    <tr>
      <td align="left" valign="top">adı</td>
      <td align="left" valign="top"><select name="tarih_ogradisoyadi" id="tarih_ogradisoyadi">
        <?php
do {  
?>
        <option value="<?php echo $row_Recordset1['ogradi']?> <?php echo $row_Recordset1['ogrsoyadi']?>"><?php echo $row_Recordset1['ogradi']?> <?php echo $row_Recordset1['ogrsoyadi']?></option>
        <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?> 
      </select></td>
    </tr>
    <tr>
      <td align="left" valign="top">tarihi</td>
      <td align="left" valign="top">
	  Gün : <input name='gun' type='text' />
Ay : <input name='ay' type='text'>
Yıl : <input name='yil' type='text' /></td>
    </tr>
    <tr>
      <td align="left" valign="top">ders</td>
      <td align="left" valign="top"><select name="ders" id="ders">
        <?php
do {  
?>
        <option value="<?php echo $row_Recordset2['mat']?>"><?php echo $row_Recordset2['mat']?></option>
          <?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  $rows = mysql_num_rows($Recordset2);
  if($rows > 0) {
      mysql_data_seek($Recordset2, 0);
	  $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  }
?>
      </select></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top"><input type="submit" name="Submit" value="gönder"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);
?>

mat sütününü date yaptım fakat hep kayıt olan tarih 0000-00-00. Bunu nasıl yazdığım tarih gibi kaydedebilirim???

Link to comment
Share on other sites

  • 2 hafta sonra ...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...