طھط*ظ„ظٹظ„ ظ…ط´ط§ظƒظ„ Sql + ط±ط³ط§ظ„ط© طھط¸ظ‡ط± ظپظٹ ط*ط§ظ„ ظ„ظ… ظٹطھظ… ط*ط°ظپ ظ…ظ„ظپ ظ…ط¹ظٹظ†



بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته
جميعنا نعلم، أن أول مايقوم ببرمجته المبرمج هو ملف Config وملف connect هذان الملفان هما المسؤلان عن الإتصال بالـ MySql واليوم أضع لكم درس مفصل لذيذ للغاية عن كيفية، إظهار المشاكل الواقعة في ملف config بصفحة جميلة للغاية لعرض الخطأ + طريقة مبتكرة لسهولة الدعم الفني !!

طبعا قبل أن أبدا، أحب أن أقول أن جميع هذه الأكواد مسحوبة من برنامج MaxBusines الذي سيتم طرحه بالقريب العاجل، وهي مفتوحة ويمكنك نزع الحقوق منها !!

بالبداية نبدأ بعمل بملف config.php
## وهذا هو الكود code الخاص به ##
رمز PHP:
<code style="white-space:nowrap"> <code> <?php
/*================================================= ==========*\
|| ################################################## ######## ||
|| # MaxBusines - version $edition # ||
|| # Copyright 2014-2014 MaxWorld Ltd. All Rights Reserved. # ||
|| # Programing By MaxImum. # ||
|| # ------------ MaxImum IS NOT FREE SOFTWARE ------------ # ||
|| ################################################## ######## ||
\*================================================ ===========*/

# Informal : File preparation

/*@ DATABASE CONNECT @*/
/*DATABASE SERVER NAME*/
$config&#91;'HOST'&#93; = ('localhost');
/*DATABASE NAME*/
$config&#91;'NAME'&#93; = ('MaxBusines');
/*DATABASE USER NAMW*/
$config&#91;'USER'&#93; = ('root');
/*DATABASE PASSWORD*/
$config&#91;'PASS'&#93; = ('1111');
/*@ DATABASE CONNECT END @*/

/*@ SETTINGS SCRIPT @*/
$set&#91;'SMARTYPATH'&#93; = ('D:/AppServ/www/Max/attacher/Smarty/');
/*@ SETTINGS SCRIPT END @*/

/*! END !*/
</code> </code>

*** طبعا لو نلاحظ أنني لم أضع وسم ?> في نهاية الكود code وهو ليس ضروري في هذا الملف الا اذا رغبت وضعه فالأمر عائد إليك

ثم نكتب كود code ملف connect.php
## وهذا هو الكود code الخاص به ##
رمز PHP:
<code style="white-space:nowrap"> <code> <?php
/*================================================= ==========*\
|| ################################################## ######## ||
|| # MaxBusines - version $edition # ||
|| # Copyright 2014-2014 MaxWorld Ltd. All Rights Reserved. # ||
|| # Programing By MaxImum. # ||
|| # ------------ MaxImum IS NOT FREE SOFTWARE ------------ # ||
|| ################################################## ######## ||
\*================================================ ===========*/

/*@ FETCHING FILE SETTINGS @*/
require_once ("config.php");

/*@ FETCHING FILE SETTINGS END @*/

/*================================================= ========*/
$info&#91;'TITLE'&#93; = ('ERROR DATABASE - CANT CONNECT MYSQL');
@
$link = mysql_pconnect($config&#91;'HOST'&#93;,$config&#91;'USER'&#93;,$config&#91;'PASS'&#93;
if (!
$link){
$info&#91;'NUM'&#93; = (BASE1."");
$info&#91;'TEX'&#93; = ( ( mysql_error() ) );
$date&#91;'EMUM'&#93; .= "Date: " . date("l dS of F Y h:i:s A") . "\n";
require_once ((
"error_database_page.html") );
exit();
}
$db = mysql_select_db($config&#91;'NAME'&#93;,$link);
if (!
$db){
$info&#91;'NUM'&#93; = (BASE2."");
$info&#91;'TEX'&#93; = ( ( mysql_error() ) );
$date&#91;'EMUM'&#93; .= "Date: " . date("l dS of F Y h:i:s A") . "\n";
require_once ((
"error_database_page.html") );
exit();
}
/*================================================= ========*/

?>
</code> </code>

طبعا لنفهم هذا الملف جيدا
الدالة : $info['TITLE'] مسؤلة عن عنوان الصفحة وهي ليست ضرورية.
الدالة : $info['NUM'] وهي رمز الخطأ ويمكنك تغير الرمز (BASE1).
الدالة : $info['TEX'] مسؤلة عن عرض معلومات حول الخطأ
الدالة : $date['EMUM'] مسؤلة عن عرض توقيت الخطأ، ويوجد بها مشكلة وهي التحديث update المستمر للتوقيت مازلت احاول حل هذا الخطأ !!

ننطلق الأن لملف error_database.html
## وهذا هو الكود code الخاص به بالمختصر الشديد ##
رمز Code:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;><html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot;><head><meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /><title> ERROR DATABASE</title><style type=&quot;text/css&quot;> /* <![CDATA[ */ * { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: &quot;Lucida Grande&quot;, Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } #wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } .panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px #A9B8C2; } #errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } #errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } /* ]]> */ </style></head><body id=&quot;errorpage&quot;><div id=&quot;wrap&quot;> <div id=&quot;page-header&quot;> <a href=&quot;./&quot;> Return to index page</a> </div> <div id=&quot;acp&quot;> <div class=&quot;panel&quot;> <div id=&quot;content&quot;> <h1> ERROR DATABASE</h1> <div>SQL ERROR [ mysqli ]<br> &nbsp;Error Num = [<? echo $info['NUM'] ?>]<br> &nbsp;Error Date = [<? echo $date['EMUM'] ?>]<br /><br /><? echo $info['TEX'] ?><br /><br /> An sql error occurred while fetching this page. Please contact an administrator if this problem persists.</div> </div> </div> </div> <div id=&quot;page-footer&quot;> Powered by MaxBusines © 2014, 2014, 2014, 2014 <a href=&quot;http://www.maxservs.com/MaxImum&quot;>MaxImum Team</a> </div></div></body></html>
الأن نجي ع الكلاس الحلو والي هو لعرض رسالة عند وجود ملف معين لم يتم حذفه !!
## هذا هو الكود code ##



رمز PHP:
<code style="white-space:nowrap"> <code> if ((is_dir("install") AND (!file_exists("install/safe.ms"))))
{
$info&#91;'NUM'&#93; = (ISTOL1."");
include_once(
'includes/system/error/error_site.html');
exit;
}
</code> </code>

شرح طريقةه
الملف : install/safe.ms يعني لازم يكون داخل ملف install ملف اسمه safe.ms عشان ماتجي الرسالة، وهذا الملف مسؤل عن حماية install وشغلته طويلة، بشرح طريقةه بدرس مفصل ثاني
includes/system/error/error_site.html هذا الملف هو ملف الرسالة

## وهذا الكود code الخاص به ##
رمز Code:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;rtl&quot;> <head> <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /> <title>ERROR IN SITE</title> <style type=&quot;text/css&quot;> /* <![CDATA[ */ * { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: &quot;Lucida Grande&quot;, Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } #wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } .panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px #A9B8C2; } #errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } #errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em Tahoma, &quot;Lucida Grande&quot;, Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } /* ]]> */ </style> </head> <body id=&quot;errorpage&quot;><div id=&quot;wrap&quot;> <div id=&quot;page-header&quot;> <a href=&quot;./&quot;>تحديث update الصفحة</a> </div> <div id=&quot;acp&quot;> <div class=&quot;panel&quot;> <div id=&quot;content&quot;> <h1>هناك مشكلة بالنظام</h1> <div> <p style=&quot;text-align: right&quot;>على مايبدو، النظام لم يجد ملف الحماية، هل أنت متأكد من تنصيب setup النظام ؟؟<br> &nbsp;رمز الخطأ <span lang=&quot;ar-sa&quot;>[<? echo $info['NUM'] ?>]</span><br /> <br /> <br /> <span lang=&quot;ar-sa&quot;>الرجاء مراجعة مركز الدعم لـ </span>MaxImum <span lang=&quot;ar-sa&quot;>لحل هذه المشكلة !!</span></div> </div> </div> </div> <div id=&quot;page-footer&quot;> Powered by MaxBusines © 2014, 2014, 2014, 2014 <a href=&quot;http://www.maxservs.com/MaxImum&quot;>MaxImum Team</a> </div></div></body></html>
تحياتي لكم جميعا، روح الشتاء











©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى©