2012-05-24 4 views
1

나는 다음과 같은 테이블이있는 HTML 파일이 아닌 객체() 멤버 함수 형식으로 전화 :치명적인 오류 :

<form action="wedding-ajax-support.php" method="get" id="wedding-table"> 
<table border="0"; align="center"> 
    <tr> 
    <th scope="col">Key</th> 
    <th scope="col">Value</th> 
    </tr> 
    <tr> 
    <td><label for="date">Select the date on which your party will take place (mm/dd/yyyy): </label></td> 

    <td> 
     <input name="date" type="text" class="larger" id="date" size="12" /> 
    </td> 
    </tr> 
    <tr> 
    <td><label for="catering">Type the catering grade you would like (from 1 to 5) : </label></td> 
    <td><input name="catering" type="text" class="larger" id="catering" size="5" /></td> 
    </tr> 
    <tr> 
    <td><label for="size">Type the number of people you are expecting to attend: </label></td> 
    <td><input name="size" type="text" class="larger" id="size" size="5" /></td> 
    </tr> 
    <tr> 
    <td>Find me available venues, based on my preferences: </td> 
    <td><input type="submit" name="submit" id="submit" value="GO!" class="larger" /></td> 
    </tr> 
</table> 

One of those inputs is the date. That's the only thing I'm concerned about for now, to keep things simple.

On another file, wedding-ajax-support.php (on which I organize all of my php code) I have this amongst other code:

$date = DateTime::createFromFormat('m/d/Y', $_GET['date']); 

$ 날짜 = $ date-> format ('Ym-d'); // 사용자가 입력 한 날짜와 데이터베이스의 날짜가 다른 형식의 날짜 형식을 변경합니다.

And then a simple echo $date; just to test it.

그런 다음, 다시 내 주요 파일에서, 내가 넣어

<script type="text/javascript"> 

$ ("# 결혼식 테이블") 부하 ("결혼식 아약스 - support.php.");

JQuery와 AJAX를 통해 사용 변경된 형식 날짜 테이블을 대체한다.

표가 있어야하는 웹 페이지를로드 할 때 메시지가 표시됩니다. "치명적인 오류 :/disk/diskh/zco/cotm2의 비 오브젝트에서 구성원 함수 형식()을 호출하십시오. /public_html/wedding/wedding-ajax-support.php on line 23 전화 스택 : 0.0002 333936 1. {main}() /disks/diskh/zco/cotm2/public_html/wedding/wedding-ajax-support.php:0 " .

Any ideas/suggestions would be appreciated, thanks in advance!

+0

문제를 묻는 날짜의 텍스트 필드를 사용하지 마십시오. 캘린더 (스크립트)를 사용하면 형식을 더 잘 표현할 수 있습니다. –

답변

0

은 "GET"변수들은 URL 쿼리 매개 변수로를 통해 전달되는 웹 서버에 의해 PHP에 대한 설정입니다. 귀하의 경우에는 페이지를 "wedding-ajax-support.php"으로로드하므로 _GET 변수가 실제로 비어 있음을 의미합니다.

0

오류가

$date = DateTime::createFromFormat('m/d/Y', $_GET['date']); 

의 결과가 DateTime의 인스턴스가 아니라 the php doc for DateTime 언급로 지정된 매개 변수를 기반으로 인스턴스를 작성할 수없는 경우 대부분 false 때문에이 false가 반환됩니다 있음을 알려줍니다.

더 목적없는, false의 방법을 format()를 호출하려고

$date = $date->format('Y-m-d'); 

에 따라서.

createFromFormat이 실패하는 이유를 알아야합니다. $_GET['date']은 구문 분석 할 수없는 형식이거나 비어있는 형식 일 수 있습니다. 확인하려면 var_dump($_GET)을 시도하십시오.

다른 답변으로는 $_GET 변수가 URL에 추가되므로 $_GET['date']을 설정하려면 URL은 wedding-ajax-support.php?date=xyz과 같아야합니다.

불행히도, 나는 당신이 자바 스크립트로하려고 한 것을 얻지 못했다.

편집 :이 게시물은 매우 오래된 것입니다. 전에 보지 못했어요. 미안 해요.