user1247071
user1247071

Reputation:

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--c

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

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');

Upvotes: 0

Views: 2885

Answers (2)

xkeshav
xkeshav

Reputation: 54052

you need to fetch the data from as mysql_query() returns only link identifier, from manual:

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);

Upvotes: 5

dan-lee
dan-lee

Reputation: 14502

You need to fetch the result before using it as variable!

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

See mysql_result()

Upvotes: 1

Related Questions