Hiển thị kết quả từ 1 đến 5 / 5
-
20-06-2012 05:43 #1
Registered User
- Tham gia
- 25-06-2006
- Bài viết
- 94
- Like
- 0
- Thanked 4 Times in 3 Posts
lỗi Fatal error: Allowed memory size of 134217728 bytes exhausted và đường dẫn
Mình tạo ra 4 file khác nhau:
index.php = > chứa đường dẫn include với body.php và menu.php
menu.php => nằm trong folder templatePHP Code:<!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" />
<link rel="stylesheet" type="text/css" href="CSS/myform.css" />
<title>Ebay Management System</title>
</head>
<body background="image/VietMartBackground.jpg">
<table width="100%" border="1">
<tr>
<td>
<form name="FormSearch" action="../function/searchProcess.php" method="post" />
<input name="searchText" title="searchText" type="text" width="400"/>
<input name="SearchButton" title="SearchButton" Type="Submit" value="Search"/>
</form>
</td>
</tr>
<tr>
<td>
<?php
include 'template/menu.php';
?>
</td>
</tr>
<tr>
<td>
<?php
include 'template/body.php';
?>
</td>
</tr>
</table>
</body>
</html>
menu.css => nằm trong folder CSSPHP Code:<link rel="stylesheet" type="text/css" href="../CSS/menu.css" />
<ul id="nav">
<li>
<a href="index.php?page=body">Home</a>
</li>
<li>
<a href="#">Supplier</a>
<ul>
<li><a href="index.php?page=supplierAdd" name="supplierAdd">Add New Suppliers</a></li>
<li><a href="index.php?page=supplierList" name="supplierList">List All Suppliers</a></li>
</ul>
</li>
<li>
<a href="#">Items</a>
<ul>
<li><a href="index.php?page=itemAdd" name="itemAdd">Add New Items</a></li>
<li><a href="index.php?page=itemList" name="itemList">List All Items</a></li>
</ul>
</li>
<li>
<a href="#">Catalogue</a>
<ul>
<li><a href="index.php?page=catalogueAdd" name="catalogueAdd">Add New Catalogue</a></li>
<li><a href="index.php?page=catalogueList" name="catalogueList">List All Catalogues</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Sale</a>
<ul>
<li><a href="index.php?page=dailySaleRecords" name="dailySaleRecords">Daily Sale Records</a></li>
<li><a href="index.php?page=totalProfitChecking" name="totalProfitChecking">Total Profit Checking</a></li>
</ul>
</li>
<li>
<a href="#">Ebay Problem Collection</a>
<ul>
<li><a href="index.php?page=problemAdd" name="problemAdd">Add New Problems</a></li>
<li><a href="index.php?page=problemList" name="problemList">List All Problems</a></li>
</ul>
</li>
</ul>
body.php => chứa SWITCH CASE code.PHP Code:/*------------------------------------*\
NAV
\*------------------------------------*/
#nav{
list-style:none;
font-weight:bold;
margin-bottom:10px;
/* Clear floats */
float:left;
width:100%;
/* Bring the nav above everything else--uncomment if needed.
position:relative;
z-index:5;
*/
}
#nav li{
float:left;
margin-right:10px;
position:relative;
}
#nav a{
display:block;
padding:5px;
color:#fff;
background:#333;
text-decoration:none;
}
#nav a:hover{
color:#fff;
background:#6b0c36;
text-decoration:underline;
}
/*--- DROPDOWN ---*/
#nav ul{
background:#fff; /* Adding a background makes the dropdown work properly in IE7+.
Make this as close to your page's background as possible (i.e. white page == white background). */
background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#nav ul li{
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float:none;
}
#nav ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:-40px; /* Bring back on-screen when needed */
}
#nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background:#6b0c36;
text-decoration:underline;
}
#nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none;
}
#nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#333;
}
ở đây, mình có tới 2 trường hợp xảy ra lỗiPHP Code:<?php
$page = isset($_GET***91;'page'***93;) ?$_GET***91;'page'***93; : 1;
switch ($page){
case "supplierAdd":
include("supplierAdd.php");
break;
case "supplierList":
include("supplierList.php");
break;
case "itemAdd":
include("itemAdd.php");
break;
case "itemList":
include("itemList.php");
break;
case "catalogueAdd":
include("catalogueAdd.php");
break;
case "catalogueList":
include("catalogueList.php");
break;
case "dailySaleRecords":
include("dailySaleRecords.php");
break;
case "totalProfitChecking":
include("totalProfitChecking.php");
break;
case "problemAdd":
include("problemAdd.php");
break;
case "problemList":
include("problemList.php");
break;
default:
include ("body.php");
}
?>
1/ Trường hợp 1 có 2 lỗi
Lỗi ko hiển thị kiểu dáng menu

nhưng các đường truyền đều ok hết ko bị lỗi
lỗi báo ở index.php
=> cái này làm sao sửa lỗi đây bạn.Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes) in D:\xampp\htdocs\EBAY\template\body.php on line 40
2/ Lỗi báo ở đường truyền
Nếu mình ko thông qua index.php mà bật ngay menu.php thì có giao diện đúng như mình muốn

nhưng sau đó bấm vào bất kì trên menu thì nó báo OBJECT NOT FOUND

Làm sao sửa các lỗi trên vậy các bạn
-
22-06-2012 06:35 #2
Registered User
- Tham gia
- 10-03-2012
- Bài viết
- 24
- Like
- 1
- Thanked 4 Times in 4 Posts
Trong file body .php, ban de la "include ("body .php")". Nhu vay file body .php trong nhieu truong hop se include chinh no, roi file body .php duoc include lai include mot file body .php khac nua... Do vay ma moi het memory.
-
24-06-2012 04:13 #3
Registered User
- Tham gia
- 25-06-2006
- Bài viết
- 94
- Like
- 0
- Thanked 4 Times in 3 Posts
Mình trình bày dữ liệu trong supplier, nếu chưa có thì báo tin còn có thì liệt kê ra nhưng bị báo lỗi ở dòng
Nhưng mà trong dữ liệu trong supplier của mình chưa có data nào cả vậy mà nó cũng ko báo tin gì luôn. Làm sao bắt nó báo tin đây bạn
đây là code của trang
Ngoài ra khi khi trang index.php ra thì hiện ra lỗiPHP Code:<?php
error_reporting();
$listSQL = "SELECT * FROM supplier";
$listQuery = mysql_query ($listSQL, $con);
$listResult = mysql_fetch_assoc ($listQuery);
while ($listResult){
if ($listResult = ""){
echo "NO record in the database";
} else {
echo'<table width="100%" border="1">';
'<tr>';
'<td width="11%">Supplier Number</td>';
'<td width="77%">{$row***91;"supplierID"***93;}</td>';
'<td width="12%">More Information</td>';
'</tr><tr>';
'<td>Supplier Name</td>';
'<td>{$row***91;"supplierName"***93;}</td>';
'<td>Edit</td>';
'</tr>';
'<tr>';
'<td>Supplier Service</td>';
'<td>{$row***91;"supplierService"***93;}</td>';
'<td>Delete</td>';
'</tr>';
'</table>';
}
}
mysql_close($con);
?>
Code:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes) in D:\xampp\htdocs\ebay\TEMPLATE\display.php on line 13
sao lại báo là quá tải bộ nhớ ??? làm sao khắc phục được ???PHP Code:<!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>EBAY MANAGEMENT SYSTEM</title>
<link rel="stylesheet" type="text/css" href="CSS/menu.css" />
<link rel="stylesheet" type="text/css" href="CSS/dataForm.css" />
</head>
<?php
error_reporting();
require_once ("FUNCTION/connect.php");
?>
<body>
<table width="100%" border="1">
<tr>
<td colspan="2">
<form name="searchForm" action="" method="post">
<input name="searchText" type="text" width="100" />
<input name="searchSubmit" type ="Submit" value="Search" />
</form>
</td>
</tr>
<tr>
<td colspan="2">
<?php
include ("TEMPLATE/menu.php");
?>
</td>
</tr>
<tr>
<td width="75%">
<?php
include ("TEMPLATE/display.php");
?>
</td>
<td width="25%"> </td>
</tr>
</table>
</body>
</html>
Mong bạn giúp đỡ dùm, thanks a lot
-
24-06-2012 18:35 #4
Moderator
- Tham gia
- 24-06-2012
- Location
- Hồ Chí Minh
- Bài viết
- 142
- Like
- 30
- Thanked 32 Times in 24 Posts
Đầu tiên, lỗi không hiển thị css là do bạn đặt ID bị sai.
Trong css của bạn là
nghĩa là ul phải nằm trong 1 cái thẻ có ID là nav, trong khi code html của bạn làCode:#nav ul ...
Để sửa, bạn đặt cái thẻ parent của thẻ ul đó, đặt cho nó id là nav. Đơn giản là wrap cái ul của bạn thành thế nàyCode:<ul id="nav" ...
Ngoài ra khi bạn vào trang index thì -> đường dẫn tới file css của bạn bị sai. Bạn hãy thay bằng đường dẫn tuyệt đối (từ tên miền) hoặc đường dẫn tương đối với file index.phpCode:<div id="nav"> <ul> ... </ul> </div>
Mình nghĩ chỗ đó nên thay thành thế này
<link rel="stylesheet" type="text/css" href="./CSS/menu.css" />
-> thay 2 dấu chấm bằng 1 dấu chấm (xin lỗi mình chưa đủ post để trích bài ..., ddth vô đối)
--------------------------------
Còn lỗi php của bạn là do bạn xài dòng này
mà cuối dòng lặp, bạn không lấy row data khác cho nóCode:while ($listResult)
Cụ thể thì code của bạn sẽ có dạng thế này
Xin nói thêm là code cũ của bạn chỗ dòng nàyCode:while ($listResult) { //code cũ của bạn ở đây //thêm dòng này vào $listResult = mysql_fetch_assoc ($listQuery); }
nên đổi thành thế nàyCode:if ($listResult = ""){ //1 dấu bằng
Mình sửa lại nội dung file supplier như thế nàyCode:if ($listResult == ""){ //2 dấu bằng để so sánh
Welcome to PHP. Thẻ PHP trong ddth bị lỗi (lâu rồi) nên mình dùng thẻ code để bạn dễ copy.Code:<?php error_reporting(); $listSQL = "SELECT * FROM supplier"; $listQuery = mysql_query ($listSQL, $con); if(!mysql_num_rows($listQuery)){ echo "NO record in the database"; } while ($listResult= mysql_fetch_assoc ($listQuery)){ //thường khi dùng mysql_fetch_assoc hay array ... người ta thường loop như thế này //if ($listResult == ""){ //dòng này thực ra không cần // echo "NO record in the database"; //} else { echo'<table width="100%" border="1">'; '<tr>'; '<td width="11%">Supplier Number</td>'; '<td width="77%">{$row***91;"supplierID"***93;}</td>'; '<td width="12%">More Information</td>'; '</tr><tr>'; '<td>Supplier Name</td>'; '<td>{$row["supplierName"]}</td>'; '<td>Edit</td>'; '</tr>'; '<tr>'; '<td>Supplier Service</td>'; '<td>{$row["supplierService"]}</td>'; '<td>Delete</td>'; '</tr>'; '</table>'; //} } mysql_close($con);
Khi thấy thông báo lỗi như vầy:
--> thì lỗi vòng lặp nó xảy ra ở line đó đó. Lỗi Allowed memory size of 134217728 bytes exhausted thường xảy ra khi bạn dùng dòng lặp mà nó rơi vào trường hợp vô hạn hoặc dùng đệ quy mà cũng bị đệ quy vô hạn. Ví dụCode:Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6144 bytes) in __FILE__ __LINE__0
hoặcCode:while(true){ }
Code:function a(){ b(); } function b(){ a(); } a(); // lỗiĐược sửa bởi antipro.vn lúc 18:57 ngày 24-06-2012
-
27-06-2012 12:34 #5
Registered User
- Tham gia
- 25-06-2006
- Bài viết
- 94
- Like
- 0
- Thanked 4 Times in 3 Posts
tuyệt quá, cám ơn bạn antipro.vn nhìu lém


Quote
Bookmarks