الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ظهور صفحه بيضاء عند استعراض الكود بالمتصفح

بدأه silent-sa في 12 أكتوبر 2009 · 11 رد · 1,178 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه ،،

كيف حالكم يااخواني

انا جالس اصمم موقع

وعملت الجداول في phpmyadmin

وعملت ملف الكونفق

وكمان سويت ملف للتاكد من اتصال القاعده

وفعلا اتصلت بالقاعده بنجاح

فبديت اسوي صفحه اندكس

وعملت هذا الكود


<?php
session_start();
require_once "script/connect_to_mysql.php";

$sqlCommand = "SELECT id,linklabel FROM pages ORDER BY pageorder ASC";
$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());
// myconnection بالمتغيرات في الكونفق

$menuDisplay = '';
while ($row = mysqli_fetch_array($query)){
$pid = $row["id"];
$linklabel = $row["linklabel"];

$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a>';
}
mysqli_free_result($query);
//mysql_close($myConnection);
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Website</title><style type="text/css">
<!--
body {
background-image: url(backgraund.jpg);
background-repeat: repeat;
}
body,td,th {
color: #FFF;
}
a:link {
color: #33F;
text-decoration: none;
}
a:visited {
color: #33F;
text-decoration: none;
}
a:hover {
color: #FFF;
text-decoration: underline;
}
a:active {
color: #FFF;
text-decoration: none;
}
-->
</style></head>

<body>
<table width="800" border="0" align="center" cellpadding="6">
<tr>
<th width="362" height="80" align="left" bgcolor="#333333" scope="col">$Header</th>
<th width="408" align="left" bgcolor="#333333" scope="col">$Custom</th>
</tr>
</table>
<table width="800" height="298" border="0" align="center" cellpadding="6">
<tr>
<th width="207" height="271" align="left" valign="top" bgcolor="#333333" scope="col"><p><?php echo $menuDisplay; ?></p>
<p></p></th>
<th width="563" align="left" valign="top" bgcolor="#333333" scope="col">$Body</th>
</tr>
</table>
<table width="800" border="0" align="center" cellpadding="6">
<tr>
<th align="left" bgcolor="#333333" scope="col">$Footer</th>
</tr>
</table>
<p> </p>
</body>
</html>

المشكله هي عندما استعرض الاندكس تظهر صفحه بيضاء والتصميم لايظهر

ياليت تفيدوني هل الكود فيه اخطاء ؟

#2

المفروض انه ما في خطأ الا في السطر التالي

while ($row = mysqli_fetch_array($query)){

عدله وخليه

while ($row = mysql_fetch_array($query)){

وانت فتحت الـSESSION وما سكرتها

واي استفسار انا جاهز

FineDesign For Graphic and WebDesign

ForEach(Minute in MyLife)

MyExperience ++;

#3

هلا اخوي ibu_love

حبيبي انا عدلت الخطاء الي قلت عليه والغيت SESSION

وشغلت الكود بس للاسف المشكله لا زالت موجوده :(

<?php

require_once "script/connect_to_mysql.php";

$sqlCommand = "SELECT id,linklabel FROM pages ORDER BY pageorder ASC";
$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());
//  myconnection بالمتغيرات في الكونفق

$menuDisplay = '';
while ($row = mysql_fetch_array($query)){
	$pid = $row["id"];
	$linklabel = $row["linklabel"];

	$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a>';
}
mysql_free_result($query);
//mysql_close($myConnection);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Website</title><style type="text/css">
<!--
body {
	background-image: url(backgraund.jpg);
	background-repeat: repeat;
}
body,td,th {
	color: #FFF;
}
a:link {
	color: #33F;
	text-decoration: none;
}
a:visited {
	color: #33F;
	text-decoration: none;
}
a:hover {
	color: #FFF;
	text-decoration: underline;
}
a:active {
	color: #FFF;
	text-decoration: none;
}
-->
</style></head>

<body>
<table width="800" border="0" align="center" cellpadding="6">
  <tr>
    <th width="362" height="80" align="left" bgcolor="#333333" scope="col">$Header</th>
    <th width="408" align="left" bgcolor="#333333" scope="col">$Custom</th>
  </tr>
</table>
<table width="800" height="298" border="0" align="center" cellpadding="6">
  <tr>
    <th width="207" height="271" align="left" valign="top" bgcolor="#333333" scope="col"><p><?php echo $menuDisplay; ?></p>
    <p></p></th>
    <th width="563" align="left" valign="top" bgcolor="#333333" scope="col">$Body</th>
  </tr>
</table>
<table width="800" border="0" align="center" cellpadding="6">
  <tr>
    <th align="left" bgcolor="#333333" scope="col">$Footer</th>
  </tr>
</table>
<p> </p>
</body>
</html>
#4

صراحة اخي انا مو شايف اي خطأ بالكود

دققت عليه ما فيه غلط

ما بعرف يمكن يجي اللي اخبر مني ويطلعلك الخطأ

او ارفع لنا المشروع نجربه ونحدد وين الخطأ

بالتوفيق

FineDesign For Graphic and WebDesign

ForEach(Minute in MyLife)

MyExperience ++;

#5

هلا اخووي

المشروع في بدايته

ملفين الى الان الاول الكونفق


<?php


$db_host = "localhost";

$db_username = "هنا اليوزر";

$db_pass = "الباسورد";

$db_name = "اسم القاعده";


$myConnection = mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");


?>

الملف الثاني وهو البدايه index


<?php
session_start();
require_once "script/connect_to_mysql.php";

$sqlCommand = "SELECT id,linklabel FROM pages ORDER BY pageorder ASC";
$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());
// myconnection بالمتغيرات في الكونفق

$menuDisplay = '';
while ($row = mysql_fetch_array($query)){
$pid = $row["id"];
$linklabel = $row["linklabel"];

$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a>';
}
mysql_free_result($query);
//mysql_close($myConnection);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Website</title><style type="text/css">
<!--
body {
background-image: url(backgraund.jpg);
background-repeat: repeat;
}
body,td,th {
color: #FFF;
}
a:link {
color: #33F;
text-decoration: none;
}
a:visited {
color: #33F;
text-decoration: none;
}
a:hover {
color: #FFF;
text-decoration: underline;
}
a:active {
color: #FFF;
text-decoration: none;
}
-->
</style></head>

<body>
<table width="800" border="0" align="center" cellpadding="6">
<tr>
<th width="362" height="80" align="left" bgcolor="#333333" scope="col">$Header</th>
<th width="408" align="left" bgcolor="#333333" scope="col">$Custom</th>
</tr>
</table>
<table width="800" height="298" border="0" align="center" cellpadding="6">
<tr>
<th width="207" height="271" align="left" valign="top" bgcolor="#333333" scope="col"><p><?php echo $menuDisplay; ?></p>
<p></p></th>
<th width="563" align="left" valign="top" bgcolor="#333333" scope="col">$Body</th>
</tr>
</table>
<table width="800" border="0" align="center" cellpadding="6">
<tr>
<th align="left" bgcolor="#333333" scope="col">$Footer</th>
</tr>
</table>
<p> </p>
</body>
</html>

معليش خيوو باتعبك شويه بس لانه اول سكربت ليه :)

وياليت من الاخوان يساعدونا

#6

أولاً أنت تستعمل mysqli و هي تختلف عن mysql (بالأحرى إضافة لها) , لذلك استعمل mysqli في كل عمليات قاعدة البيانات ..

ضع هذا الكود في كود الاندكس و شوف النتيجة ..

<?php
session_start();
require_once "script/connect_to_mysql.php";

$sqlCommand = "SELECT id,linklabel FROM pages ORDER BY pageorder ASC";
$query = mysqli_query($myConnection,$sqlCommand) or die (mysqli_error());
//  myconnection بالمتغيرات في الكونفق

$menuDisplay = '';
while ($row = mysqli_fetch_array($query)){
	$pid = $row["id"];
	$linklabel = $row["linklabel"];

	$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a>';
}
mysqli_free_result($query);
//mysqli_close($myConnection);

?>

ثم غير مؤقتاً لون فونت البودي من الابيض الى الاسود لكي ترى رسائل الخطأ التي تنشأ ....

#7

هلا اخووي karakas

شكرا لي المساعده وتم تغير اللون الى الاسود ولكن المشكله مازالت قائمه :rolleyes:

وينكم شباب :(

تم تعديل هذه المشاركة بواسطة silent-sa في 16 أكتوبر 2009 في 23:58

#8

أخي الكريم في الصفحة الأولى الخاصه بالإعدادات قم بتعديل هذه الأسطر

$myConnection = mysql_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");
$db_select=mysql_select_db($db_name);

السطر الثاني إضافه ... يعني مش موجود عندك فقط قم بإضافته

إذا عمل الموقع كان بها وإن لم يعمل تكون فعلا تستخدم قاعدة بيانات من نوع mysqli عندها سأقوم بتعديل الكود لك لكي يعمل

وإذا عمل الموقع تكون إعدادات البي أتش بي تعمل على إخفاء أو عدم إظهار الأخطاء.

CMS Sfhati , Website Generator


نظام إدارة المحتوى صفحتي ... جربه الآن 


 


small-logo.png

#9

صراحة اخي الكود مليان اخطاء رح صححه لك خطوة خطوة بس التصحيح الكامل انت سويه حتى تستفاد وماتكرر الخطا

نجي اول شي

$myConnection = mysql_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");

استخدم الدالة

mysql_select_db

لغرض الاتصال بقاعدة البيانات فلايجوز ان تتكتب اسم القاعدة بدالة الاتصال يعني احذفه وسوي اتصال بالدالة اعلاه

ثاني شي

$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());

هذه الدالة معاملاتها غلط يعني لازم بالاول تحط المتغير اللي يمثل الاستعلام وبعدين متغير الاتصال يعني تصير بهذه الطريقة

$query = mysql_query($sqlCommand,$myConnection) or die (mysql_error());

ثالث شي

$pid = $row['id'];

$linklabel = $row['linklabel'];

يعني تستتخدم ' بدل من " لانو هذه مصفوفة مرافقة

رابع شي

انت موحاط اي كود يرسل نتيجة للمتصفح يعني لازم تكتب

echo $menuDisplay;

صحح الاخطاء اعلاه ولو مااشتغل رح اعطيك الكود كامل لانو انا صححته واشتغل عندي

hope is not a plan

----------------

#10

:tantrum: يا أساتذتي الكرام .... الأخ يستعمل مكتبة MySqli في أكواده... وهي إضافة الى mysql التقليدية و تختلف عنها حيث تحاكي منهج الOOP...

و فيها وظائف رائعة جداً و قوية .

http://www.php.net/manual/en/mysqli.summary.php

أعتقد أن الخطأ عنده انه خلط في بين MYSQL التقليدية و MYSQLI و في نفس الكود ...........

بارك الله فيكم ...

تم تعديل هذه المشاركة بواسطة karakas في 18 أكتوبر 2009 في 00:07

#11
اقتباس
أعتقد أن الخطأ عنده انه خلط في بين MYSQL التقليدية و MYSQLI و في نفس الكود ...........

بارك الله فيكم ...

جزء من الاخطاء هي الخلط والجزء الاخر هي اخطاء برمجية مثل الخطا الموجود في المصفوفة المرافقة وعدم ارسال نتيجة الى المتصفح ليتم عرضه

hope is not a plan

----------------

#12

السلام عليكــم ورحمـة الله وبركاتــه ،،

استاذ bastr3

تم اضافه الداله ولم يشتغل المشروع


$db_select=mysql_select_db($db_name);

ولقد علمت ان الخطاء بعد اضافه الداله هو في السطر

باني وضعت الاتصال قبل الاستعلام

فاشتغل الموقع الان اشكر لك مساعدتك

$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());

................................................................................

................

اخي العزيز والحبيب just-gal

تم حل المشكله

فمثل ماتفضلت اخي بان الخطاء هنا


$query = mysql_query($myConnection,$sqlCommand) or die (mysql_error());

المفروض مثل ماقلت تصبح هكذا


$query = mysql_query($sqlCommand,$myConnection) or die (mysql_error());

شكرا لك اخي تعلمت منك معلومه مفيده ايضا

................................................................................

الاخ karakas

صراحه الموضوع الي في الرابط جدا جميل اشكرك ايضا

..............................................

اصبح الموقع يعمل الان

الله يعطيكم العافيه جميعا فانتم اساتذه

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…