我在MySQL中有一个DATETIME列(默认为NULL)并尝试插入Empty或NULL值.但我收到"不正确的日期时间值:''"错误消息.如果我插入'NULL',那么我得到"不正确的日期时间值:'NULL'"错误消息.如何在此列中插入空白或NULL值?谢谢你的任何建议.
这是代码.
if (empty($_POST["date_field"]))
{
$Date1 = 'NULL';
}
else
{
$Date1 = strtotime($_POST["date_field"]);
$Date1 = date("Y-m-d H:i:s", $Date1);
}
INSERT INTO Table1(date_field) VALUES('" .$Date1. "');
Run Code Online (Sandbox Code Playgroud) 如何从.cs文件访问母版页属性?我尝试了下面的代码,但我无法访问它.请让我知道.
public int TypeID
{
get
{
return Convert.ToInt32(this.ViewState["TypeID"]);
}
set
{
this.ViewState.Remove("TypeID");
this.ViewState.Add("TypeID", value);
}
}
Run Code Online (Sandbox Code Playgroud)
var pageHandler = HttpContext.Current.CurrentHandler;
if (pageHandler is System.Web.UI.Page)
{
typeId = Convert.ToInt32((System.Web.UI.Page)pageHandler).Master.TypeID;
}
Run Code Online (Sandbox Code Playgroud) 我有以下字符串.我收到以下错误.能告诉我可能出错的地方吗?
Unexpected character encountered while parsing value: C. Path '', line 0, position 0.
JsonTextReader error: System.Exception {Newtonsoft.Json.JsonReaderException}
Run Code Online (Sandbox Code Playgroud)
这是我从客户端获取的JSON字符串.
Content-Type: application/json
Content-Disposition: attachment; filename="postData.json"
{"name":"test44","age":"66","gender":"B","dob":"10\/10\/2003","file":null}
Run Code Online (Sandbox Code Playgroud)
这是我使用JSON.NET解析的代码.
JsonTextReader reader = new JsonTextReader(new StringReader(json));
while (reader.Read())
{
if (reader.Value != null)
Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
else
Console.WriteLine("Token: {0}", reader.TokenType);
}
Run Code Online (Sandbox Code Playgroud) 我的下拉列表显示为空.我不确定我的查询是否返回任何记录.如何确定我的查询是否返回任何结果?这是我的代码.请告诉我.我坚持这个问题.
<?php $link = mysql_connect("localhost", "root", "root");
if (!$link) { die('Could not connect: ' . mysql_error()); }
echo 'Connected successfully';
mysql_select_db("mydb");
$sql = "SELECT state_id, state_code FROM states";
$result = mysql_query($sql) or die(mysql_error());
?>
<p>
<select name="vers">
<?
while($row = mysql_fetch_array($result)){
echo "<option value=\"".$row['state_id']."\">".$row["state_code"]."</option>";
}
?>
</select>
<?
mysql_close($link);
?>
Run Code Online (Sandbox Code Playgroud) 我收到'不正确的整数值:''列country_id'。有时我的下拉菜单隐藏在表单中。所以我不确定如何处理这种情况。这是我的代码。谢谢你的帮助。
$countryId = isset($_POST['country']) ? $_POST['country'] : 0;
$inserSQL = "INSERT INTO Table1(country_id) VALUES('" .$countryId. "')";
$Result1 = mysql_query($inserSQL ) or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)