لمحترفي الويبPHP - معمو — الصفحة ١٢٩

129 استخدام ما تعلمناه في تطبيق سلة تسوق بسيط... cart_inc.php يتضمن الملف cart_inc.php التوابع التي تقوم بجل العمل المطلوب من أجل cart.php. وقد قمنا بفصل هذه التوابع هنا لتسهيل تخصيص مظهر cart.php. البرنامج النصي cart_inc.php define(SECURE_URL, "http://localhost/advancedphp/chapter05/"); define (IMAGE_URL, 1. 2. મેં હં. <? 3. 4. 5. "http://localhost/advancedphp/chapter05/images/"); define(SHIPPING_COST, "7.00"); define (COMPANY_NAME, "Widget Industrial Inc."); 6. define (CREDIT_AUTH_URL, "finishorder.php"); 7. define (COMPANY_EMAIL, "[email protected]"); 8. 9. 10. 11. 12. 13. 14. 15. $host = "localhost"; 16. 17. 18. 19. 20. 21. function connect() { ini_set("include_path", "G:\apache\Apache\php\pear"); require_once("DB.php"); $type = "mysql"; $username = "php"; $password = "password"; $database = "cart"; $dsn = $type "://" $username • $host "/" . $database; $dbconn = DB::connect($dsn); errortrap ($dbconn); $dbconn->setFetchMode (DB_FETCHMODE_ASSOC); return $dbconn; $password. "@" 22. } //end connect 23. 24. 25. 26. function error trap ($result) { if (DB::isError ($result)) { 27. 28.2 } 29. ?><h3>There was an error!</h3><? die($result->getMessage()); } //end errortrap
ص١٢٩

نص مستخرج آليًا من الصورة، وقد يقع فيه خطأ.