2012-04-25 30 views
0

Fatal error: Uncaught exception 'Exception' with message 'DateTime::_construct() [datetime.--construct]: Failed to parse time string (Resource id #7) at position 0 (R): The timezone could not be found in the database' in Z:\home\plati\www\view.php:21 Stack trace: #0 Z:\home\plati\www\view.php(21): DateTime->_construct('Resource id #7') #1 {main} thrown in Z:\home\plati\www\view.php on line 21致命错误:未捕获的异常“异常”与消息“日期时间:: __构建体()[<a href='datetime.--construct'>datetime.--c

have ithis error what do? line 20...

$date = mysql_query("SELECT date FROM sondaje WHERE id = '$id'") or die("Error! DataBase Name Incorrect!"); 
$bdate = new DateTime("$date"); 
$bdate->modify('+8 day'); 
$yearz = $bdate->format('Y'); 
$monthz = $bdate->format('m'); 
$dayz = $bdate->format('d'); 
$hourz = $bdate->format('H'); 
$minutz = $bdate->format('i'); 
$secndz = $bdate->format('s'); 
+1

这是一个家庭作业?? – diEcho 2012-04-25 11:35:26

+3

对不起,堆栈溢出不是阅读手册的方便选择。有很多关于如何使用(过时的)mysql扩展的例子。 – 2012-04-25 11:38:42

回答

6

you need to fetch the data from as mysql_query()只返回链路标识符,从手动:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

$fetch_date = mysql_query("SELECT date FROM sondaje WHERE id = '$id'") 
      or die("Error! DataBase Name Incorrect!"); 

$date = mysql_fetch_assoc($fetch_date); 
+0

谢谢你会尝试 – 2012-04-25 11:38:00

+1

为什么downvoted ?? – diEcho 2012-04-25 11:40:09

+0

对不起,我没有故意这样做。我不能撤销,如果你不编辑...奇怪。 – 2012-04-25 11:50:35

1

你需要使用它作为变量之前抓取的结果!

$bdate = new DateTime(mysql_result($result, 0, 0)); 

mysql_result()参见

相关问题