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

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
  • 3
    Sorry but Stack Overflow is not a convenient alternative to reading the manual. There're plenty of examples on how to use the (obsolete) mysql extension. Commented Apr 25, 2012 at 11:38

2 Answers 2

5

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);
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I didn't do this on purpose. I can't revoke if you don't edit... strange.
1

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

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

See mysql_result()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.