首页 \ 问答 \ 提交时无法在数据库中插入时间戳(Can't insert timestamp in database when submitting)

提交时无法在数据库中插入时间戳(Can't insert timestamp in database when submitting)

我有这个表单和流程页面。
在表单页面上,有两个隐藏的输入id和reg_time值在“结束”时设置为null,当执行没有问题但是在行reg_time我得到的函数00:00:00在表用户中设置的时间戳。 有什么建议吗?

  function post($POST)
 {   
   $POST = array_map('trim', $_POST);
   $hash = "$2y$10$";
   $salt = "nekiludistringzahash22";
   $his = $hash . $salt;
   $POST['pass'] = crypt($_POST['pass'],$his);
   return $POST;  
 }

 $sql = "insert into users values(:" . implode(",:", array_keys(post($_POST))) . ");";




try{
     $db = new PDO('mysql:host=localhost;charset=utf8;dbname=dbname','root','');
     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

 }catch (PDOException $e) 

{

     die("Conn problem " . $e->getMessage());
} 

$reg = $db->prepare($sql);
$reg->execute(post($_POST));

和形式

 <form action="exp2.php" method="post">
<input type="hidden" name="id" value="null">

<input type="text"name="uname">
<input type="text"name="pass">
<input type="text"name="name">
<input type="text"name="lname">
<input type="submit">

<input type="hidden" name="reg_time" value = "null">
</form>

I have this form and process page.
On a form page, there are two hidden inputs id and reg_time values set to null at the "end " when executing no problem with id but under the row reg_time I get 0000-00-00 00:00:00 timestamp set in table users. Any suggestions why?

  function post($POST)
 {   
   $POST = array_map('trim', $_POST);
   $hash = "$2y$10$";
   $salt = "nekiludistringzahash22";
   $his = $hash . $salt;
   $POST['pass'] = crypt($_POST['pass'],$his);
   return $POST;  
 }

 $sql = "insert into users values(:" . implode(",:", array_keys(post($_POST))) . ");";




try{
     $db = new PDO('mysql:host=localhost;charset=utf8;dbname=dbname','root','');
     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

 }catch (PDOException $e) 

{

     die("Conn problem " . $e->getMessage());
} 

$reg = $db->prepare($sql);
$reg->execute(post($_POST));

and form

 <form action="exp2.php" method="post">
<input type="hidden" name="id" value="null">

<input type="text"name="uname">
<input type="text"name="pass">
<input type="text"name="name">
<input type="text"name="lname">
<input type="submit">

<input type="hidden" name="reg_time" value = "null">
</form>

原文:https://stackoverflow.com/questions/38418099
更新时间:2023-11-09 11:11

最满意答案

好吧,我终于找到了问题所在。 在使用Instruments Time Profiler更仔细地查看之后,我注意到在copyImageBlockSetPNG上花了很多时间,这让我首先相信我是从每个帧的磁盘加载图像。 结果,有人已经有这个问题CGContextDrawImage是否可以动态解压缩PNG? 它结束了我每帧加载内存的结果,但不是来自磁盘,而是每帧都以png格式从内存中解压缩。

在该帖子中有一个解决方案,其中包括将图像写入上下文并从中获取图像的未压缩副本。

这是有效的,但我发现其他方式,我相信它更有效

NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
                                             forKey:(id)kCGImageSourceShouldCache];
NSData *imageData = [NSData dataWithContentsOfFile:@"path/to/image.png"]];
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)(imageData), NULL);
CGImageRef atlasCGI = CGImageSourceCreateImageAtIndex(source, 0, (__bridge CFDictionaryRef)dict);
CFRelease(source);

希望能帮助到你!


Well, I finally figured out where the problem was. After looking more carefully with Instruments Time profiler, I noticed a lot of time was spent in copyImageBlockSetPNG , which was what made me believe first that I was loading the image from disk for every frame. turn out, somebody already had this problem Does CGContextDrawImage decompress PNG on the fly?, and it ended being true that I was loading the memory each frame, but not from disk, instead it was being uncompressed from memory in png format for every frame.

In that post theres a solution, which consists in writing the image to a context and getting from it an uncompressed copy of the image.

That works, but I found other way which I believe It's a little bit more efficient

NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
                                             forKey:(id)kCGImageSourceShouldCache];
NSData *imageData = [NSData dataWithContentsOfFile:@"path/to/image.png"]];
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)(imageData), NULL);
CGImageRef atlasCGI = CGImageSourceCreateImageAtIndex(source, 0, (__bridge CFDictionaryRef)dict);
CFRelease(source);

Hope it helps!

相关问答

更多
  • 您可以使用-renderAsVectorInContext:atPoint:scale:方法将符号绘制到CGContext 。 创建一个上下文,将符号绘制到其中,并使用UIGraphicsGetImageFromCurrentImageContext()创建一个UIImage 。 You can use the -renderAsVectorInContext:atPoint:scale: method to draw the symbol into a CGContext. Create a contex ...
  • 以下将做你正在寻找的东西。 您可以使用键盘上的向上和向下↓键在动画中向前和向后导航。 XAML
  • 您可以直接操作images数组,并注入过滤/缓存的图像。 它要求您预加载图像,过滤它们,然后替换SpriteSheet中的图像。 当数组中的所有图像都被加载后,您也可以从SpriteSheet中获取complete事件,并在那里执行该操作: // pseudocode spritesheet.on("complete", function(e) { for (var i=0; i
  • 好吧,我终于找到了问题所在。 在使用Instruments Time Profiler更仔细地查看之后,我注意到在copyImageBlockSetPNG上花了很多时间,这让我首先相信我是从每个帧的磁盘加载图像。 结果,有人已经有这个问题CGContextDrawImage是否可以动态解压缩PNG? 它结束了我每帧加载内存的结果,但不是来自磁盘,而是每帧都以png格式从内存中解压缩。 在该帖子中有一个解决方案,其中包括将图像写入上下文并从中获取图像的未压缩副本。 这是有效的,但我发现其他方式,我相信它更有效 ...
  • 由于您使用的得分值和文件名之间似乎存在直接关系(意味着00 - > '00 .png',1 - > '01 .png',... 70 - > '70 .png'等)并且在得分= 70之后,整个序列重复,这样做的一种方式是首先,摆脱70的乘法,然后在前面添加0以获得单个数字得分。 这是一个功能就是这样: -- Given a score, returns correct picture name -- eg. for score = 01 returns 01.png local function getFi ...
  • 您应该拥有一个具有background-image的单个类名(如.NavShowHide ),然后使用更具体的类来定义background-position ,而不是在每个类上声明一个background-image : .NavShowHide { background-image:url('../Images/navigation-spritesheet.png'); height: 44px; width: 44px; display: inline-block; ...
  • 按照兰尼建议的方式工作: 通过预加载器(而不是Spritesheet)将其作为JSON文件加载。 这解决了我的问题,因为我能够访问我的其他参数。 您只需要将所有链接的图像预加载到清单中,因为在这种情况下它不会为您执行此操作。 谢谢! Got it to work as it was suggested by Lanny: Loaded it as a JSON file by preloader (not as a Spritesheet). That solved my problem as I was ...
  • EaselJS SpriteSheet类支持两种格式。 简单版本支持spritesheet中所有图像的单个宽度/高度 frames: {width:64, height:64, count:20, regX: 32, regY:64} 复杂版本为每个图像定义矩形 // The 5th value is the image index per the list defined in "images" (defaults to 0). frames: [ // x, y, width, ...
  • 由于您的spriteSheet对象没有默认构造函数,因此问题是您在playerSprite类中有一个spriteSheet成员,该成员需要使用一个参数构造。 那个成员是image 。 class spriteSheet { spriteSheet(string path); // <-- This is your constructor }; class playerSprite { public: playerSprite(int xpos, int ypos ...
  • 你的问题是,你创建了一个带有image-url的SpriteSheet,这已经触发了一个加载过程,preload-js队列实际上什么也没有加载,因为图像的加载已经在进行中,所以“onComplete”-event在图像实际加载之前总是被触发 - 这是有道理的,因为不需要加载图像两次 我已经更新了你的jsfiddle并添加了一些评论: http : //jsfiddle.net/K4TmS/1/ (完整代码) spriteSheet = new createjs.SpriteSheet({ ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)