เปลี่ยนชื่่อ table แล้วขึ้น Warning: session_start() [function.session-start]:
พอดี เปลี่ยนชื่อตารางครับ แล้วมันก็ขึ้นอย่างนี้เลยครับ ก่อนเปลี่ยนไม่มีปัญหาเลยครับ
Code
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\AppServ\www\09521591\index.php:1) in C:\AppServ\www\09521591\index.php on line 4
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\09521591\index.php:1) in C:\AppServ\www\09521591\index.php on line 4
ส่วนcode ก็ตามนี้ครับ
Code (PHP)
<?
ob_start();
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
session_start();
require("connect/connect.php");
require("connect/function.php");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>::: RealOne :::</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {
font-size: 14px;
font-style: italic;
color: #CC0000;
}
-->
</style>
</head>
<body topmargin="0">
<table width="950" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#C5E2AF">
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php require_once('head.php'); ?></td>
</tr></table></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#C5E2AF">
<tr>
<td width="30%" valign="top">
<?php require_once('menuleft.php'); ?>
</td>
<td width="40%" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="546" height="24" valign="top"><div align="center">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', '450','height','316','align','middle','src','flash/bann','quality' ,'high','pluginspage','http://www.macromedia.com/go/getflashplayer' ,'movie','flash/bann' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="450" height="316" align="middle">
<param name="movie" value="flash/bann.swf">
<param name="quality" value="high">
<embed src="flash/bann.swf" width="450" height="316" align="middle" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object>
</noscript></div></td>
</tr>
<tr>
<td height="310" valign="top">
<table width="462" border="0" align="center" background="image/login/bg.png">
<tr>
<td><hr width="96%" color="#f2f2f6"></td>
</tr>
<tr>
<td>
<table width="421" height="22" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td width="8"> </td>
<td width="389"><div align="center"><img src="image/kindproduct.png" width="445"></div></td>
<td width="9"> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="378">
<?
//============ อ่านข้อมุลหมวด
$sqlCat="select * from 09521591category where 1=1 order by CatID asc ";
$queryCat=mysql_query($sqlCat);
echo"<table><tr>";
$i=0;
while($resutCat=mysql_fetch_array($queryCat))
{
$i++;
echo "<td>";
?>
<table width="180" height="134" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="60" valign="top"><div align="center"><a href="product.php?CatID=<?=$resutCat["CatID"];?>"><img src="picture/<?=$resutCat["Picture"];?>" width="60" height="60" border="0" /></a></div></td>
</tr>
<tr>
<td valign="top"><div align="center"> <a href="product.php?CatID=<?=$resutCat["CatID"];?>">
<?=$resutCat["CategoryName"];?>
<strong>
<?="(".num_record("09521591product","where 1 and CatID='".$resutCat["CatID"]."' ").")";?>
</strong> </a></div></td>
</tr>
</table>
<?
//============ แสดงแถวละ 3 ตัว
echo"</td>";
if(($i)%3==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?> </td>
</tr>
</table>
<hr width="96%" color="#f2f2f6">
<br>
<table width="465" border="0" align="center" background="image/login/bg.png">
<tr>
<td> <table width="421" height="22" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td width="8"> </td>
<td width="389"><div align="center"><img src="image/newproduct.png" width="403" height="40"></div></td>
<td width="9"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="378">
<?
//============ อ่านรายการสินค้าล่าสุด
$sqlNewPro="select * from 09521591product where 1=1 and New='Yes' order by ProductID DESC limit 0,6 ";
$queryNewPro=mysql_query($sqlNewPro);
echo"<table align=center><tr>";
$i=0;
while($resutNewPro=mysql_fetch_array($queryNewPro))
{
$i++;
echo "<td>";
?>
<table width="121" height="105" border="0" align="center" cellpadding="3" cellspacing="10">
<tr>
<td height="60" valign="top"><div align="center"><a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>"><img src="picture/<?=$resutNewPro["Picture"];?>" width="127" height="105" border="0"></a></div></td>
</tr>
<tr>
<td valign="top"><div align="center"> <a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>">
<?=$resutNewPro["ProductName"];?>
</a><br>
ปกติ
<?="(<s>".number_format($resutNewPro["PriceNormal"], 2,'.',',')."</s>";?>
บาท) <br>
<font color="#FF0000"><strong>พิเศษ</strong></font>
<?="(".number_format($resutNewPro["Price"], 2,'.',',');?>
บาท) <br>
ค่าจัดส่ง
<?="(".number_format($resutNewPro["PriceSend"], 2,'.',',');?>
บาท) </div></td>
</tr>
</table>
<?
//============ แสดงแถวละ 2
echo"</td>";
if(($i)%2==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?> </td>
</tr>
</table>
<hr width="96%" color="#f2f2f6"> </td>
</tr>
</table></td>
<td width="30%" valign="top">
<?php require_once('menuright.php'); ?>
</td>
</tr>
<tr>
<td colspan="3" valign="top">
<?php require_once('down.php'); ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL
ประวัติการแก้ไข 2011-09-10 15:38:33
Date :
2011-09-10 15:34:26
By :
shindo
View :
1272
Reply :
6
ส่วน connect กับ Function
Code (PHP)
<?
/*=============== ติดต่อฐานข้อมูล =================*/
$host="localhost";
$user_name="root";
$pass_word="";
$db="Bookzone2";
$admin_email = "[email protected] ";
mysql_connect( $host,$user_name,$pass_word) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
mysql_query("SET NAMES UTF8");
mysql_query("SET character_set_connection=utf8");
?>
Code (PHP)
<?php
//============== Function ในการแทรกข้อมูล ==============
function insert($field,$value,$table)
{
$sql = "INSERT INTO $table ($field) VaLUES ($value)";
//echo $sql;
$result= mysql_query($sql);
return $result;
}
//============== Function ในการลบข้อมูล ==============
function delete($table,$condition)
{
$sql ="delete from $table $condition";
$result = mysql_query($sql);
return $result;
}
//=============== Function ในการแก้ไขข้อมูล ==================
function update($table,$command,$condition)
{
$sql = "UPDaTE $table SET $command $condition";
$result = mysql_query($sql);
return $result;
}
//=============== Function ในการเลือกข้อมูล ==================
function select($table,$condition)
{
$sql = "select * from $table $condition";
//echo $sql;
$dbquery = mysql_query($sql);
$result= mysql_fetch_array($dbquery);
return $result;
}
//=============== Function ในการเลือกข้อมูลทั้งหมด ==================
function selectalldate($table,$condition,$listby)
{
$sql = "select * from $table $condition $listby";
//echo $sql;
$dbquery = mysql_query($sql);
return $dbquery;
}
//=============== select Reccord Max or Min================== // อาจจะใช้ในการ ดึง เฉพาะฟิวส์ หรือรวมค่า นับค่า
function selectMaxOrMin($maxormin,$field,$table,$condition)
{
$sql = "select $maxormin($field) as $field from $table $condition";
$dbquery = mysql_query($sql);
$result= mysql_fetch_array($dbquery);
return $result;
}
//=============== Function ในการเลือกข้อมูล==================
function selectFistOrLast($table,$condition,$fieldlist,$bylist)
{
$sql = "select * from $table $condition order by $fieldlist $bylist";
$dbquery = mysql_query($sql);
$result= mysql_fetch_array($dbquery);
return $result;
}
//=============== Function ในกาตรวจสอบตัวอักษรข้อมูล ==================
function checkcharector($temp)
{
$temp=Trim(eregi_replace ( "'" , "" , $temp));
$temp=Trim(eregi_replace ( "\"" , """ , $temp));
return $temp;
}
//=============== Function ในการนับจำนวนแถว ==================
function num_record($table,$condition)
{
$sql = "select * from $table $condition";
$dbquery = mysql_query($sql);
$num_rows = mysql_num_rows($dbquery);
return $num_rows;
}
//=============== Function ในการนับตรวจสอบค่าว่าง ==================
function JscheckValueNull($form,$field,$msg)
{
echo"\nif(trim(document.$form.$field.value)=='')\n";
echo"{\n";
echo"alert('$msg');\n";
echo"document.$form.$field.focus();\n";
echo"return false;\n";
echo"}\n\n";
}
?>
Date :
2011-09-10 15:44:01
By :
shindo
ใช้ nodepad++ เขียนหรือเปล่าครับ?
Date :
2011-09-10 18:51:22
By :
Manussawin
ครับใช้ Notepad++ เขียน UTF-8 ครับ
Date :
2011-09-11 11:59:06
By :
shindo
ครับ บางโปรแกรม default ที่ utf-8 with bom ต้องเลือก without-bom ครับ
Date :
2011-09-11 21:00:48
By :
ikikkok
Load balance : Server 05