<i id='GNo2m'><tr id='GNo2m'><dt id='GNo2m'><q id='GNo2m'><span id='GNo2m'><b id='GNo2m'><form id='GNo2m'><ins id='GNo2m'></ins><ul id='GNo2m'></ul><sub id='GNo2m'></sub></form><legend id='GNo2m'></legend><bdo id='GNo2m'><pre id='GNo2m'><center id='GNo2m'></center></pre></bdo></b><th id='GNo2m'></th></span></q></dt></tr></i><div id='GNo2m'><tfoot id='GNo2m'></tfoot><dl id='GNo2m'><fieldset id='GNo2m'></fieldset></dl></div>

<small id='GNo2m'></small><noframes id='GNo2m'>

    <tfoot id='GNo2m'></tfoot>

      • <bdo id='GNo2m'></bdo><ul id='GNo2m'></ul>

        <legend id='GNo2m'><style id='GNo2m'><dir id='GNo2m'><q id='GNo2m'></q></dir></style></legend>

        插入日期的php/Mysql查询失败

        时间:2023-10-11
              <legend id='oBcis'><style id='oBcis'><dir id='oBcis'><q id='oBcis'></q></dir></style></legend>
            1. <small id='oBcis'></small><noframes id='oBcis'>

                  <tbody id='oBcis'></tbody>

              • <tfoot id='oBcis'></tfoot>
                <i id='oBcis'><tr id='oBcis'><dt id='oBcis'><q id='oBcis'><span id='oBcis'><b id='oBcis'><form id='oBcis'><ins id='oBcis'></ins><ul id='oBcis'></ul><sub id='oBcis'></sub></form><legend id='oBcis'></legend><bdo id='oBcis'><pre id='oBcis'><center id='oBcis'></center></pre></bdo></b><th id='oBcis'></th></span></q></dt></tr></i><div id='oBcis'><tfoot id='oBcis'></tfoot><dl id='oBcis'><fieldset id='oBcis'></fieldset></dl></div>
                  <bdo id='oBcis'></bdo><ul id='oBcis'></ul>
                  本文介绍了插入日期的php/Mysql查询失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经搜索了很长时间,但我不明白为什么我的查询不适用于日期.

                  I have been searching for quite a while now and I can't figure out why my query isn't working for dates.

                  我希望将它作为日期导入到我的数据库中,这是从更高层的选择,所以我在这里.

                  I want it to be imported to my database as a Date, this is a choice from higher up so here I am.

                  $insert_query = "INSERT INTO enrties(
                  `datum` )
                  VALUES (
                  '".mysql_real_escape_string($_SESSION['Datum'])."')
                  

                  上面几页之前我用这段代码来填充$_SESSION

                  a few pages before the above i use this piece of code to fill the $_SESSION

                  $DateDag = $_POST['Dag'];
                  $DateMaand = $_POST['Maand'];
                  $DateJaar = $_POST['Jaar'];
                  switch ($dateMaand)
                  {
                  case 'Januari': $DateMaand = '01'; break;
                  case 'Februari': $DateMaand = '02'; break;
                  case 'Maart': $DateMaand = '03'; break; 
                  case 'April': $DateMaand = '04'; break; 
                  case 'Mei': $DateMaand = '05'; break;   
                  case 'Juni': $DateMaand = '06'; break;  
                  case 'July': $DateMaand = '07'; break;  
                  case 'Augustus': $DateMaand = '08'; break;  
                  case 'September': $DateMaand = '09'; break; 
                  case 'Oktober': $DateMaand = '10'; break;   
                  case 'November': $DateMaand = '11'; break;  
                  case 'December': $DateMaand = '12'; break;      
                  }
                  $_SESSION['Datum'] = $DateDag. '-'. $DateMaand. '-'. $DateJaar;
                  

                  我想将日期导入为 SQL 日期格式(最好是 DD-MM-YYYY 格式).

                  I want to have the date imported as a SQL Date format (preferably DD-MM-YYYY format).

                  解决了,开关中出现了一个错误显然,不确定是什么,但它有效;)

                  SOLVED, there was a mistake in the switch Apparantly, not really sure what but it works ;)

                  推荐答案

                  MySQL 的日期格式实际上是 YYYY-MM-DD,所以如果你想插入一个日期(猜测你的数据字段是 Date 或 Datetime)你必须以这种方式设置您的字符串.

                  The MySQL date format is actually YYYY-MM-DD, so if you want to insert a date (guessing your datum field is Date or Datetime) you have to set up your string in that way.

                  如果你想以不同的方式插入你的日期,你应该使用这个:

                  If you want to insert your date in a different way you should use this:

                  INSERT INTO enrties (datum) VALUES (str_to_date('01/02/2000', '%d/%m/%Y')); 
                  

                  但这将始终以 YYYY-MM-DD 方式保存日期,因为这是 mysql 的默认设置.

                  but this will save always the date in YYYY-MM-DD way, since is the default for mysql.

                  这篇关于插入日期的php/Mysql查询失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从我的 mysql 中选择最新的 5 行 下一篇:查询在 phpmyadmin 中有效,但在 PHP 脚本中无效

                  相关文章

                    <bdo id='nhZWr'></bdo><ul id='nhZWr'></ul>
                • <legend id='nhZWr'><style id='nhZWr'><dir id='nhZWr'><q id='nhZWr'></q></dir></style></legend>

                      <i id='nhZWr'><tr id='nhZWr'><dt id='nhZWr'><q id='nhZWr'><span id='nhZWr'><b id='nhZWr'><form id='nhZWr'><ins id='nhZWr'></ins><ul id='nhZWr'></ul><sub id='nhZWr'></sub></form><legend id='nhZWr'></legend><bdo id='nhZWr'><pre id='nhZWr'><center id='nhZWr'></center></pre></bdo></b><th id='nhZWr'></th></span></q></dt></tr></i><div id='nhZWr'><tfoot id='nhZWr'></tfoot><dl id='nhZWr'><fieldset id='nhZWr'></fieldset></dl></div>
                      <tfoot id='nhZWr'></tfoot>

                    1. <small id='nhZWr'></small><noframes id='nhZWr'>