PHP include warnings -
i have 2 php-files.
source/dao/winkelwagendao.php
here i:
include_once($_server['document_root'].'/itbee/model/winkelwagenitem.php');
then have: source/model/winkelwagenitem.php -> getters , setters
now on onchange
event in jquery ajax-request winkelwagendao file, catch request in dao file , call appropriate function -> updateaantal()
catch:
if(isset($_post['function'])) { $action = $_post['function']; switch ($action) { case 'updateaantal' : echo "\naan te passen aantal voor productid: " . $_post['productid'] . " gebruik functie: " . $_post['function'] . " set aantal naar: " . $_post['aantal']; winkelwagendao::updateaantal($_post['productid']); } }
updateaantal()
function:
public static function updateaantal($productid) { if (isset($_cookie["winkelwagen"])) { //cookie exists? $array = self::getwinkelwagenitems(); $index = 0; //positie bijhouden foreach ($array $product) { if ($productid == $array[$index]->getproductid()) { //echo $productid . " == " . $array[$index]->getproductid(); $array[$index]->setaantal($_post['aantal']); $serializearray = serialize($array); setcookie("winkelwagen", $serializearray); break; //quit if match } else { $index++; } } } else { echo "this cookie did not exist"; } }
seems can not access getters winkelwagenitem php class because include_once not working correctly. although think path correct? reason why use $_server['document_root']
.
when error in console , 2 warnings:
warning: include_once(./dao/productdao.php): failed open stream: no such file or directory in /applications/mamp/htdocs/itbee/model/winkelwagenitem.php on line 2
warning: include_once(): failed opening './dao/productdao.php' inclusion (include_path='.:/applications/mamp/bin/php/php5.6.6/lib/php') in /applications/mamp/htdocs/itbee/model/winkelwagenitem.php on line 2
warning: cannot modify header information - headers sent (output started @ /applications/mamp/htdocs/itbee/model/winkelwagenitem.php:2) in /applications/mamp/htdocs/itbee/dao/winkelwagendao.php on line 137
the warnings failed include second line of /itbee/model/winkelwagenitem.php file. include tries find ./dao/productdao.php file, doesn't exist. should search in winkelwagenitem.php solve issue. didn't post code here.
remarks of question irrelevant problem.
Comments
Post a Comment