Click here to Skip to main content
15,894,297 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
<form action="index.php" method="GET"><input type="submit" name="back" value="back">
PHP
<?php echo $dateback1; ?>
</form>

PHP
$monate = array(01=>"Januar", 02=>"Februar", 03=>"März", 04=>"April", 05=>"Mai", 06=>"Juni", 07=>"Juli", 08=>"August", 09=>"September", 10=>"Oktober", 11=>"November", 12=>"Dezember");
$monat = date ("n");


PHP
if (isset ($_GET['vor']));
{
$back = $monate[$monat];
$dateback = new DateTime($back);
$dateback->modify("+1 month");
$dateback->format("m");
$dateback1 = $monate[$dateback]. "nbsp;"; date('Y');
}


Warning: Illegal offset type in /data/multiserv/users/750202/projects/1804127/www/Inhalte/Kalender/index.php on line xy
2012
The line xy is the line with the variable $dateback1
What is the mistake?
Posted
Updated 28-Apr-12 8:52am
v3
Comments
Mohibur Rashid 27-Apr-12 20:48pm    
dateback is a object of DateTime, and in monate indexes are integers how can you expect indecx to be found?
Chi Ller 28-Apr-12 14:55pm    
Sorry I had a few mistakes in this code here. But in the original document is everything like this now.
This code is in a document which is named index.php

Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.
http://php.net/manual/en/language.types.array.php[^]
 
Share this answer
 
here is the thing again,
C++
$dateback1 = $monate[$dateback]. "nbsp;"; date('Y');


here $dateback is a object of DateTime type object.

now i can guess you are trying get the name of month from monate

so what you need to do is get the month value from $dateback. So find out the function that return month integer value.

C++
$dateback1 = $monate[$the_month_value]. "nbsp;"; date('Y');


figure it out ;)
 
Share this answer
 
Comments
Chi Ller 29-Apr-12 16:09pm    
I don´t find something that works and I understand
Mohibur Rashid 29-Apr-12 20:40pm    
hummm, in that case open DateTime class and find the variable or the function that return the month value

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900