Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in งงครับ แก้ใขยังไงครับ จากโค้ดตัวนี้
เมื่อไม่เป็นสมาชิก โพสต์ตอบกระทู้นี้แล้ว เกิดเออเรอ แบบนี้ครับ แต่ก็สามารถ บันทึกข้อมูลได้เรียบร้อย ดังข้างล่างครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www/function.php on line 165
บันทึกข้อมูลเรียบร้อยแล้ว
function.php)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include'config.inc.php';
function ConnDB()
{
global $conn;
global $host;
global $user;
global $pwd;
global $dbName;
$conn=mysql_connect($host,$user,$pwd);
mysql_query("SET NAMES utf-8", $conn) ;
if(!$conn)
die("ไม่สามารถติดต่อกับ MySQL Server ได้");
/* เลือกใช้ฐานข้อมูล */
mysql_select_db($dbName,$conn)
or die("ไม่สามารถเลือกใช้งานฐานข้อมูล $database_name ได้");
}
function CloseDB()
{
mysql_close($conn);
}
function login($ac)
{
switch ($ac){
case 1:
if($_POST['id'] && $_POST['pwd'])
{
$name=$_POST['id'];
$pass=$_POST['pwd'];
$sql = " select * from member where user='$name' and pwd='$pass' ";
$result = mysql_query($sql);
$res=mysql_fetch_array($result);
$num=mysql_num_rows($result);
if($num==0)
{
//$error = '<BR><P align=center><font color="#FF3399">!!! Error ชื่อหรือรหัสผ่าน<br>ไม่ถูกต้อง</font></P>';
//return $error;
return -1;
}
elseif($num>0)
{
//$userlevel = $res['level'];
$uid = $res[mem_id];
$uuser = $res[user];
//if($_POST[storecookie]){
//$endtime=time() + 2678400;
$endtime=time() + 100000;
//setcookie(userlevel, $userlevel, $endtime);
setcookie('id',$uid ,$endtime);
setcookie('user',$uuser ,$endtime);
// }
//$_SESSION['userlevel']=$userlevel;
//$_SESSION['userid']=$uid;
//return -2;
}
}
break;
case 3:
//setcookie('userid',false);
break;
}
}
function logout()
{
//setcookie(userlevel,false);
setcookie('id',false);
setcookie('user',false);
}
function sheckuser(){
if(empty($_COOKIE['mem_id']) || empty($_COOKIE['user'])){
$show="<script language='javascript'> alert('ล๊อกอินก่อนนะ !') </script> <script language='javascript'>javascript:history.go(-1)</script>";
return $show;
}
}
function insert($field,$value,$table)
{
$sql = mysql_query("INSERT INTO $table ($field) VALUES ($value)");
if($sql)
{
$show="<script language='javascript'> alert('บันทึกข้อมูลเรียบร้อยแล้ว !') </script> <script language='javascript'>javascript:history.go(-1)</script>";
return $show;
}
else
{
return '<img src="frind_img/no.jpg" align="absmiddle"><font color= red>ไม่สามารถบันทึกข้อมูลได้ !</font><br>เกิดข้อผิดพลาดดังนี้'. mysql_error();
}
}
function insert2($field,$value,$table)
{
$sql = mysql_query("INSERT INTO $table ($field) VALUES ($value)");
if($sql)
{
$show='<img src="images/loading.gif" align="absmiddle"><font color= red>บันทึกข้อมูลเรียบร้อยแล้ว ';
return $show;
}
else
{
return '<img src="images/close.gif" align="absmiddle"><font color= red>ไม่สามารถบันทึกข้อมูลได้ !</font><br>เกิดข้อผิดพลาดดังนี้'. mysql_error();
}
}
function updates($table,$command,$condition)
{
$sql = "UPDATE $table SET $command $condition";
$result = mysql_query($sql);
if($result)
{
$show="<script language='javascript'> alert('แก้ไขเรียบร้อยแล้ว') </script> <script language='javascript'>javascript:history.go(-1)</script>";
return $show;
}
else
{
$show='<script language=javascript> alert(ไม่สามารถแก้ไขมูลได้มีข้อผิดพลาด !) </script> <script language=javascript>javascript:history.go(-1)</script>';
return $show;
}
}
function select($table,$condition)
{
$sql = "select * from $table $condition";
$dbquery = mysql_query($sql);
$row=mysql_num_rows($dbquery);
$result= mysql_fetch_array($dbquery);
if($row)
{
return $row;
}
//else
//{
//return mysql_error();
//}
}
function delete($table,$condition)
{
$sql ="delete from $table $condition";
$result = mysql_query($sql);
if($result)
{
return '<h1><img src="frind_img/ok.jpg" align="absmiddle">ลบข้อมูลเรียบร้อย</h1>';
}
else
{
return '<img src="frind_img/no.jpg" align="absmiddle"><font color= red>เกิดข้อผิดพลาด<br>ไม่สามารถลบข้อมูลได้ '. mysql_error();
}
}
function selections($gid,$filde)
{
$sql = "select * from member where mem_id=$gid";
$dbquery = mysql_query($sql);
$result= mysql_fetch_array($dbquery);
if($result)
{
$res=$result[$filde];
return $res;
}
else
{
return mysql_error();
}
}
function selections2($user,$filde)
{
$sql = "select * from member where user=$user";
$dbquery = mysql_query($sql);
$result= mysql_fetch_array($dbquery);
if($result)
{
$res=$result[$filde];
return $res;
}
else
{
return mysql_error();
}
}
#ฟังก์ชันแสดงวันเวลา
$ThaiMonth=array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
function ThaiDate($InputDate)
{
global $ThaiMonth;
$day=substr($InputDate,6,2);
$month=substr($InputDate,4,2);
$month=(int)$month -1;
$year=substr($InputDate,0,4);
$year=$year+543;
$month=$ThaiMonth[$month];
echo (int)$day." ".$month." ".$year;
}
function ThaiDatesale($InputDate)
{
global $ThaiMonth;
$day=substr($InputDate,8,2);
$month=substr($InputDate,5,2);
$month=(int)$month -1;
$year=substr($InputDate,0,4);
$year=$year+543;
$month=$ThaiMonth[$month];
$thaidatenew=
$thaidatenew= (int)$day." ".$month." ".$year;
return $thaidatenew;
}
#ฟังก์ชันเกี่ยวกับ inputdata-------------------------------------------------------------------------->
function inputword($txt)
{
// ป้องกันการแทรก html กับ ละเครื่องหมาย ' "
$txt=htmlspecialchars($txt);
// ป้องกันคำหยาบ
$word = array("fuck","dick","shit","f u c k","d i c k","s h i t","f.u.c.k","d.i.c.k","s.h.i.t","มึง","กู","ควย","ค ว ย","ค.ว.ย","ปี้","เหี้ย","เฮี้ย","ไอ้","สัดหมา","สัตว์หมา","ชาติหมา","สัด","เย็ด","หี");
$ban = "<font color=red>***</font>";
for ($i=0 ; $i<sizeof($word) ; $i++) {
$txt = eregi_replace($word[$i],$ban,$txt);
}
// ตรวจสอบว่า มีการป้อน url หรือ email มาหรือไม่ ถ้ามีให้ทำ link
$txt = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","<a href=\"\\1://\\2\\3\" target=\"\\2\\3\">\\1://\\2\\3</a>",$txt);
$txt = eregi_replace("([[:alnum:]]+)@([^[:space:]]*)([[:alnum:]])","<a href=mailto:\\1@\\2\\3>\\1@\\2\\3</a>",$txt);
// ให้ขึ้นบันทัดใหม่ กรณีที่มีการเคาะ Enter
$txt = eregi_replace(chr(13),"<br>",$txt);
return $txt;
}
function pstatus($sp){
if($sp==1){
$show='ยังไม่ตรวจ ?';
return $show;
}elseif($sp==2){
$show='-1';
return $show;
}elseif($sp==3){
$show='+1';
return $show;
}elseif($sp==4){
$show='+2';
return $show;
}elseif($sp==5){
$show='+3';
return $show;
}
}
/*Strip Tags UTF-8*/
function substr_utf8( $str, $from , $len ){
return preg_replace( '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'$1' , $str );
};
/*END Strip Tag UTF-8*/
function eregi_replace_utf8( $str, $from , $len ){
return preg_replace( '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'$1' , $str );
};
/*END Strip Tag UTF-8*/
function pstatus_color($sp){ ////////////////////////////// ค่าสีตาราง
if($sp==1){
$show='#996600';
return $show;
}elseif($sp==2){
$show='#FF0000';
return $show;
}elseif($sp==3){
$show='#006666';
return $show;
}elseif($sp==4){
$show='#003366';
return $show;
}elseif($sp==5){
$show='#663399';
return $show;
}
}
?>
read.php
<? include"header.php";?>
<?
session_start();
include'config.inc.php';
include'function.php';
?>
<?php require('_drawrating.php'); ?>
<?
function ranDomStr($length){
$str2ran = '0123456789'; //string ที่เป็นไปได้ที่จะใช้ในการ random ซึ่งสามารถเพิ่มลดได้ตามความต้องการ
$str_result = ""; //สตริงว่างสำหรับจะรับค่าจากการ random
while(strlen($str_result)<$length){ //วนลูปจนกว่าจะได้สตริงตามความยาวที่ต้องการ
$str_result .= substr($str2ran,(rand()%strlen($str2ran)),1); //ต่อ string จาก substring ที่ได้จากการ random ตำแหน่ง ทีละ 1 ตัว จนกว่าจะครบตรามความยาวที่ส่งมา
}
return($str_result);//ส่งค่ากลับ
}
$ran_str = randomstr(6); //สั่ง random string
?>
<!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" />
<meta name="keywords" content="<?php
$eid=$_GET[id];
$tags_select = mysql_query("SELECT name FROM `tags` WHERE `topicid`=".$eid."") or die(mysql_error());
while($tags_topic = mysql_fetch_array($tags_select)){
echo "".$tags_topic['name'].","; }
?>">
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/default.css" />
<link rel="stylesheet" type="text/css" href="css/rating.css" />
<script type="text/javascript" language="javascript" src="js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="js/rating.js"></script>
<script src="scripts/editor.js" type="text/javascript"></script>
<script language="javascript" src="Style_event.js" type="text/javascript"></script>
<script language="javascript" src="Style_cookie.js" type="text/javascript"></script>
<script language="javascript" src="Style_size.js" type="text/javascript"></script>
<script language="javascript" src="Set_text.js" type="text/javascript"></script>
<script type="text/javascript">
function bbc_highlight(something, mode)
{
something.style.backgroundImage = "url(" + (mode ? "images/bbc/bbc_hoverbg.gif)" : "images/bbc/bbc_bg.gif)");
}
</script>
<script type="text/javascript">
<!--
function Inint_AJAX()
{
try
{
return new ActiveXObject( "Msxml2.XMLHTTP" ); //IE
}
catch( e )
{
}
try
{
return new ActiveXObject( "Microsoft.XMLHTTP" ); //IE
}
catch( e )
{
}
try
{
return new XMLHttpRequest(); //Native Javascript
}
catch( e )
{
}
alert( "XMLHttpRequest not supported" );
return null;
};
//-->
</script>
<script type="text/javascript" src="tab.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<title>Dekzon >> เด็กซน วาไรตี้ต่างๆ บันเทิง คลิป ดารา ท่องเที่ยว อาหาร ฟังเพลง ดูหนัง ทีวี สาวๆ รูปภาพ << </title>
<style type="text/css">
<!--
.style5 { color: #FFFFFF;
font-weight: bold;
font-size: 13px;
}
.style6 {
color: #000000;
font-weight: bold;
}
.style9 {color: #FF0000}
.style11 {color: #0033CC}
.style12 {color: #000000}
.style13 {color: #333333}
.style14 {color: #666666}
.style16 {
color: #666666;
font-size: 12px;
font-family: tahoma;
}
.style37 { color: #FFFF99;
font-size: 10px;
}
.textwh {font-size: 12px;
font-weight: bold;
color: #FFFFFF;
}
.style38 {
font-size: 2px;
color: #E9E9E9;
}
.style1 {color: #FFFFFF}
.style22 {font-size: 14px;
color: #333333;
}
.style3 { color: #FFFFFF;
font-weight: bold;
}
.style43 { font-size: 14px;
font-weight: bold;
}
.style45 {font-size: 12px}
-->
</style>
</head>
<body>
<div id="black">
<form id="form1" name="form1" method="post" action="">
</form>
<p>
<?
include'config.inc.php';
$eid=$_GET[id];
$sqlview="update tb_newstravel set pageview=pageview+1 where n_id=$eid ";
$resview=mysql_query($sqlview);
mysql_connect( $host,$user,$pwd) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($dbName) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
$dg="$eid";
$sql="Select * From tb_newstravel where n_id='$eid'";
$ba=mysql_query($sql);
while ($d=mysql_fetch_array($ba)){
$datahead=$d[n_topic];
$sql = "SELECT COUNT( * ) FROM a_news where q_id=$_GET[id] ";
$result = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_array($result);
$alcom = $row["COUNT( * )"];
?>
</p>
<p> </p>
<form id="form2" name="form2" method="post" action="">
</form>
<div id="black2">
<table width="931" height="517" border="0">
<tr>
<td width="621" height="513" valign="top"><div id="blackLeft-p">
<div class="newheadline">
<p>หัวข้อเรื่อง : <?=$datahead;?>
<br />
<br />
</p>
<form id="form3" name="form2" method="post" action="">
<? include "ads1.php";?>
</form>
</div>
<div class="newheadline-2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="87%"><div id="sizer"><font class="time_update">
<?=ThaiDatesale($d[a_date]);?>
</font> <a class="decrease" href="#" title="Text Size --"><img src="images/font-dec.gif" width="25" height="25" border="0" /></a><a class="reset" href="#" title="Restore Text Size"><img src="images/reset.gif" width="23" height="23" border="0" /></a><a class="increase" href="#" title="Text Size ++"><img src="images/font-inc.gif" width="25" height="25" border="0" /></a>
<?
echo" <img src=images/print.gif> <a href='#' onClick=window.print()>พิมพ์หน้านี้</a><br />";
?>
</div>
</td>
<td width="13%"><a href="#" onclick="window.open('mail.php?id=<?=$d[n_id];?>','','fullscreen=no,width=410,height=410,titlebar=no,toolbar=no,statusbar=no,scrollbars=no,resizable=no')" /></a><img src="images/email_32.png" border="0" /></a><a href="http://www.facebook.com/sharer.php?u=<?php echo"".$siteurl."/readnews.php?id=$d[n_id]"; ?>"><img src="images/system/Social_Facebook.png" /></a></td>
</tr>
</table>
</div>
<div class="newheadline-rating">
<div class="vote">(ให้คะเเนนบทความ)</div>
<div class="vote-cm"><? echo rating_bar("$eid",5); ?></div>
<div class="vote-p">
<div align="right"><br />
เปิดอ่าน <strong>
<?=$d[pageview];
?>
</strong> ครั้ง ความเห็น
<?=$alcom;
?>
</div>
</div>
</div>
<div id="blackLeft-news"> <br />
<div id="pic_hover">
<? if($d[n_image]==""){
} else {?>
<?
}
?>
</div>
<?=$d[n_detail];?>
</div>
<div id="send-mail">
<h3>ขอบคุณเนื้อหาจาก :
<?=$d[n_copy];?>
<br />
<br />
</h3>
<h3 align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-3738878361761491";
/* 468x60, ถูกสร้างขึ้นแล้ว 9/7/10 */
google_ad_slot = "8434747646";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</h3>
</div>
<div id="send-mail"><a href="#"><img src="images/top-up.png" alt="" width="129" height="39" border="0" /></a> </div>
<div id="topic_content_tag">
<? }
?>
คำค้น:
<?php
$tags_select = mysql_query("SELECT name FROM `tags` WHERE `topicid`=".$eid."") or die(mysql_error());
while($tags_topic = mysql_fetch_array($tags_select)){
echo "<a href=\"tag.php?tag=".$tags_topic['name']."\">
".$tags_topic['name']."</a> ";
}
?>
<br />
</div>
</div></td>
<td width="300" valign="top"><table width="259" border="0" align="center">
<tr>
<td width="267" height="21" colspan="3"><div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-3738878361761491";
/* dekzon update 1 */
google_ad_slot = "7826946456";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></td>
</tr>
</table>
<div align="center"></div>
<table width="257" border="0" align="center">
<tr>
<td width="251" height="22" bgcolor="#003399"><img src="images/k.png" width="17" height="17" /> <span class="style5">โฆษณาผู้สนับสนุน <span class="style37">แสดงผลทุกหน้า <img src="img/new.gif" width="30" height="15" /></span></span></td>
</tr>
<tr>
<td height="257"><div align="center"><span class="clear"><a href="http://sanookthailand.com/?id=214" target="_blank"><img src="img/soonthorn.gif" alt="sanookthailand.com" width="120" height="120" border="1" /></a></span><img src="images/line.png" width="7" height="10" /><span class="clear"><a href="http://omyim.in.th" target="_blank"><img src="img/omyim.gif" alt="Omyim อมยิ้ม สถานีเพลงเพราะตลอด 24 ชม." width="120" height="120" border="1" /></a><a href="http://dekzon.com"></a></span><br />
<img src="images/line.png" width="10" height="3" /><br />
<span class="clear"><a href="http://www.idon-studio.ob.tc/" target="_blank"><img src="img/ba.gif" alt="idon-studio" width="120" height="120" border="0" /></a></span><img src="images/line.png" width="7" height="10" /><span class="clear"><img src="img/bannerdekzon.gif" alt="ป้ายโฆษณา" width="120" height="120" border="1" /><br />
</span></div></td>
</tr>
</table>
<br /></td>
</tr>
</table>
</div>
</div>
<div id="black-comment-news-ment">
<?php
// สร้างฟังก์ชั่น สำหรับแสดงการแบ่งหน้า mode modify by neesiam
function page_navigator($before_p,$plus_p,$total,$total_p,$chk_page){
global $urlquery_str;
$pPrev=$chk_page-1;
$pPrev=($pPrev>=0)?$pPrev:0;
$pNext=$chk_page+1;
$pNext=($pNext>=$total_p)?$total_p-1:$pNext;
$lt_page=$total_p-4;
if($chk_page>0){
echo "<a href='?id=$_GET[id]&s_page=$pPrev' class='naviPN'>หน้าก่อนนี้</a>";
}
if($total_p>=11){
if($chk_page>=4){
echo "<a $nClass href='?id=$_GET[id]&s_page=0'>1</a><a class='SpaceC'>. . .</a>";
}
if($chk_page<4){
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
if($i<=4){
echo "<a $nClass href='?id=$_GET[id]&s_page=$i'>".intval($i+1)."</a> ";
}
if($i==$total_p-1 ){
echo "<a class='SpaceC'>. . .</a><a $nClass href='?s_page=$i'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=4 && $chk_page<$lt_page){
$st_page=$chk_page-3;
for($i=1;$i<=5;$i++){
$nClass=($chk_page==($st_page+$i))?"class='selectPage'":"";
echo "<a $nClass href='?id=$_GET[id]&s_page=".intval($st_page+$i)."'>".intval($st_page+$i+1)."</a> ";
}
for($i=0;$i<$total_p;$i++){
if($i==$total_p-1 ){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a class='SpaceC'>. . .</a><a $nClass href='?id=$_GET[id]&s_page=$i'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=$lt_page){
for($i=0;$i<=4;$i++){
$nClass=($chk_page==($lt_page+$i-1))?"class='selectPage'":"";
echo "<a $nClass href='?id=$_GET[id]&s_page=".intval($lt_page+$i-1)."'>".intval($lt_page+$i)."</a> ";
}
}
}else{
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a href='?id=$_GET[id]&s_page=$i' $nClass >".intval($i+1)."</a> ";
}
}
if($chk_page<$total_p-1){
echo "<a href='?id=$_GET[id]&s_page=$pNext' class='naviPN'>หน้าต่อไป</a>";
}
}
/////////////////////////// สิ้นสุดฟังก์ชั่นทันที //////////////////////////////////////////////////////////
$q="select * from a_news where q_id=$_GET[id] order by a_id DESC";
//$q.="order by a_id ASC";
$qr=mysql_query($q);
$total=mysql_num_rows($qr);
$e_page=20; // จำนวนต่อหน้า
if(!isset($_GET['s_page'])){
$_GET['s_page']=0;
}else{
$chk_page=$_GET['s_page'];
$_GET['s_page']=$_GET['s_page']*$e_page;
}
$q.=" LIMIT ".$_GET['s_page'].",$e_page";
$qr=mysql_query($q);
if(mysql_num_rows($qr)>=1){
$plus_p=($chk_page*$e_page)+mysql_num_rows($qr);
}else{
$plus_p=($chk_page*$e_page);
}
$total_p=ceil($total/$e_page);
$before_p=($chk_page*$e_page)+1;
// หาจำนวนเรกคอร์ดข้อมูลในตาราง
$num_rows = mysql_num_rows($qr);
if($num_rows==''){
echo "ยังไม่มีใครตอบคำถาม";
}
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($qr);
$a_id = $result[a_id];
$a_answer = $result[a_answer];
$a_name = $result[a_name];
$a_date = $result[a_date];
$a_time = $result[email];
$ip = $result[ip];
$status = $result[status];
$number = $result[number];
$n++;
?>
<div class="comment_main">
<div class="comment_top_mm"> <strong>
<?=$number;?>
</strong> <br class="spacer" />
</div>
<div class="comment_top_detail"><span class="style12"><strong>หัวข้อ : </strong> <span class="style14">
<?=$datahead;?>
</span> </span><span class="style13"> <span class="style12"><strong>เมื่อ</strong></span> <span class="style16">
<?=ThaiDatesale($a_date);?>
<?=$a_time;?>
</span></span></div>
<?
if($status==0) {
?>
<div class="comment_top_mm_n">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="center"><img src="images/no_images.gif" width="95" height="95" /></td>
</tr>
<tr>
<td align="left"><font color="#993300">โดย :<strong>
<?=$a_name;?>
</strong></font></a> </td>
</tr>
<tr>
<td align="left">สถานะ:<strong> ผู้เยี่ยมชม</strong></td>
</tr>
<tr>
<td align="left"></td>
</tr>
</table>
<br class="spacer" />
</div>
<? }else{ ?>
<div class="comment_top_mm_n">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="center"><img src="img/mem_pic/<?=selections2("'$a_name'","mem_pic");?>" width="95" height="95" /></td>
</tr>
<tr>
<td align="left">โดย <span class="style11">:
<?=selections2("'$a_name'","user");?>
</span></td>
</tr>
<tr>
<td align="left">สถานะ: <span class="style9">สมาชิก</span></td>
</tr>
<tr>
<td align="left"><span class="style28"><span class="style6">กระทู้:
<?=select("q_webboard","where q_name='$a_name'");?>
</span></td>
</tr>
</table>
<br class="spacer" />
</div>
<p>
<? } ?>
</p>
<p> </p>
<p> </p>
<div class="comment_top_content">
<?=$a_answer;?>
<br class="spacer" />
</div>
<p> </p>
<p> </p>
<p><br class="spacer" />
</p>
</div>
<?
$i++;
}
?>
<div class="browse_page">
<?php if($total>0){ ?>
<?php
// เรียกใช้งานฟังก์ชั่น สำหรับแสดงการแบ่งหน้า
page_navigator($before_p,$plus_p,$total,$total_p,$chk_page);
}
?>
<br class="spacer" />
</div>
</div>
<p><?php
require ('captcha/smc.class.php'); // Captcah
require ('include/function.inc.php');
$smc = new SimpleMathCaptcha(); // Captcah
$step=intval($_POST['step']);
?>
</p>
<div id="black-comment-news-ment-1">
<div class="comment_main_box">
<?php
if($step!=2){
?>
<form action="#" name="frmComment" id="frmComment" enctype="multipart/form-data" method="post" onsubmit="return chk_addtopic()">
<table width="916">
<tr> </tr>
<tr>
<td> </td>
<td><input name="topic" type="hidden" id="topic" value="<? if(isset($_COOKIE[mem_id])) { echo selections("$_COOKIE[mem_id]","emails"); }?>" size="55" <? if(isset($_COOKIE[mem_id])) { ?>disabled="disabled"<?
} ?> />
</td>
</tr>
<tr>
<td colspan="2"><p id="preview" style="width:100%; background:#f3f3f3"></p></td>
</tr>
<tr>
<td colspan="2"><a href="javascript:void(0);" onclick="surroundText('', '', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/b.gif" align="bottom" width="23" height="22" alt="ตัวหนา" title="ตัวหนา" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/i.gif" align="bottom" width="23" height="22" alt="ตัวเอียง" title="ตัวเอียง" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/u.gif" align="bottom" width="23" height="22" alt="ตัวขีดเส้นใต้" title="ตัวขีดเส้นใต้" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('[strike]', '[/strike]', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/strike.gif" align="bottom" width="23" height="22" alt="ตัวขีดกลาง" title="ตัวขีดกลาง" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', '
', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/left.gif" align="bottom" width="23" height="22" alt="ชิดซ้าย" title="ชิดซ้าย" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', '
', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/center.gif" align="bottom" width="23" height="22" alt="กึ่งกลาง" title="กึ่งกลาง" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', '
', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/right.gif" align="bottom" width="23" height="22" alt="ชิดขวา" title="ชิดขวา" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="replaceText(' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/hr.gif" align="bottom" width="23" height="22" alt="เส้นขวาง" title="เส้นขวาง" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/sup.gif" align="bottom" width="23" height="22" alt="ตัวยก" title="ตัวยก" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/sub.gif" align="bottom" width="23" height="22" alt="ตัวห้อย" title="ตัวห้อย" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/move.gif" align="bottom" width="23" height="22" alt="ตัวอักษรวิ่ง" title="ตัวอักษรวิ่ง" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText(' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/img.gif" align="bottom" width="23" height="22" alt="รูปภาพ" title="รูปภาพ" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <a href="javascript:void(0);" onclick="surroundText('ข้อความ', ' ', document.forms.frmComment.message); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="images/bbc/url.gif" align="bottom" width="23" height="22" alt="ลิ้งก์" title="ลิ้งก์" style="background-image: url(images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a> <img src="images/bbc/size.gif" alt="ขนาดต้วอักษร" title="ขนาดต้วอักษร"/>
<select id="fontsize" name="fontsize" onchange="surroundText('[size=' + this.options[this.selectedIndex].value.toLowerCase() + ']', '[/size]', document.forms.frmComment.message); this.selectedIndex = 2; document.forms.frmComment.message.focus(document.forms.frmComment.message.caretPos);">
<option value="10px" >เล็กมาก</option>
<option value="11px" >เล็ก</option>
<option value="16px" selected="selected" >ปกติ</option>
<option value="20px" >ใหญ่</option>
<option value="30px" >ใหญ่มาก</option>
</select>
<img src="images/bbc/face.gif" alt="สีต้วอักษร" title="สีต้วอักษร"/>
<select id="fontcolor" name="fontcolor" onchange="surroundText('[color=' + this.options[this.selectedIndex].value.toLowerCase() + ']', '', document.forms.frmComment.message); this.selectedIndex = 0; document.forms.frmComment.message.focus(document.forms.frmComment.message.caretPos);">
<option value="black" style="color:black">ดำ</option>
<option value="silver" style="color:silver">เทาเงิน</option>
<option value="gray" style="color:gray">เทา</option>
<option value="maroon" style="color:maroon">น้ำตาล</option>
<option value="red" style="color:red">แดง</option>
<option value="purple" style="color:purple">ม่วง</option>
<option value="fuchsia" style="color:fuchsia">ชมพู</option>
<option value="navy" style="color:navy">น้ำทะเล</option>
<option value="blue" style="color:blue">น้ำเงิน</option>
<option value="aqua" style="color:aqua">ฟ้าคราม</option>
<option value="teal" style="color:teal">เขียวขี้เป็ด</option>
<option value="lime" style="color:lime">เขียวมะนาว</option>
<option value="green" style="color:green">เขียว</option>
<option value="olive" style="color:olive">เขียวมะกอก</option>
<option value="yellow" style="color:yellow">เหลือง</option>
<option value="white" style="color:white">ขาว</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"><a href="javascript:void(0);" onclick="replaceText(':em1:', document.forms.frmComment.message); return false;"> <img src="images/emo/em1.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em1:', document.forms.frmComment.message); return false;"> <img src="images/emo/em2.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em3:', document.forms.frmComment.message); return false;"> <img src="images/emo/em3.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em4:', document.forms.frmComment.message); return false;"> <img src="images/emo/em4.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em5:', document.forms.frmComment.message); return false;"> <img src="images/emo/em5.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em6:', document.forms.frmComment.message); return false;"> <img src="images/emo/em6.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em7:', document.forms.frmComment.message); return false;"> <img src="images/emo/em7.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em8:', document.forms.frmComment.message); return false;"> <img src="images/emo/em8.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em9:', document.forms.frmComment.message); return false;"> <img src="images/emo/em9.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em10:', document.forms.frmComment.message); return false;"> <img src="images/emo/em10.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em11:', document.forms.frmComment.message); return false;"> <img src="images/emo/em11.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em12:', document.forms.frmComment.message); return false;"> <img src="images/emo/em12.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em13:', document.forms.frmComment.message); return false;"> <img src="images/emo/em13.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em14:', document.forms.frmComment.message); return false;"> <img src="images/emo/em14.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em15:', document.forms.frmComment.message); return false;"> <img src="images/emo/em15.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em16:', document.forms.frmComment.message); return false;"> <img src="images/emo/em16.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em17:', document.forms.frmComment.message); return false;"> <img src="images/emo/em17.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em18:', document.forms.frmComment.message); return false;"> <img src="images/emo/em18.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em19:', document.forms.frmComment.message); return false;"> <img src="images/emo/em19.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em20:', document.forms.frmComment.message); return false;"> <img src="images/emo/em20.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em21:', document.forms.frmComment.message); return false;"> <img src="images/emo/em21.gif" border="0"/></a> <a href="javascript:void(0);" onclick="replaceText(':em22:', document.forms.frmComment.message); return false;"> <img src="images/emo/em22.gif" border="0"/></a> <a href="javascript:moreSmileys();">[เพิ่มเติม]</a> </td>
</tr>
<tr>
<td colspan="2"><textarea rows="10" name="message" id="message" style="width:97.5%" class="text_box"></textarea>
</td>
</tr>
<tr>
<td><div align="right">ผู้ตั้งกระทู้ :</div></td>
<td><? if(empty($_COOKIE['mem_id'])) {
?>
<input name="username" type="text" class="fb9" id="username" />
<?
}else{
?>
<input name="username" type="text" class="fb9" id="username" value="<? if(isset($_COOKIE[mem_id])) { echo selections("$_COOKIE[mem_id]","user"); }?>" size="20" <? if(isset($_COOKIE[mem_id])) { ?>disabled="disabled"<? } ?> />
<? } ?>
</td>
</tr>
<tr>
<td><div align="right"><img src="captcha/show.php" height="30" width="100" /></div></td>
<td><input type="text" name="code" size="5"/>
กรอกผลลัพธ์ตามภาพปรากฏ** (ถ้าผลลัพธ์ติดลบให้ใส่เครื่องหมายลบด้วย)</td>
</tr>
<tr>
<td> </td>
<td><input type="hidden" name="topicid" value="<?=$_GET[id];?>" />
<input type="hidden" value="2" name="step" />
<? if(empty($_COOKIE['mem_id'])) {
echo"<font color=red><strong>คุณยังไม่ได้เป็นสมาชิก !</strong></font>";
echo" <br />";
echo"<input type=submit value=submit name=post />";
} else {
if(isset($_COOKIE[mem_id])) { ?>
<input type="submit" value="submit" name="post" />
<? }} ?>
<!-- <input type="submit" name="Post" value="Post" /> -->
<input type="button" name="preview" value="ตัวอย่าง" onclick="onPreview();"/>
<br />
<br />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
function chk_addtopic(){
if (document.frmComment.message.value=="") {
alert("กรุณากรอกรายละเอียดด้วยครับ");
document.frmComment.message.focus();
return false;
}else if (document.frmComment.username.value=="") {
alert("กรุณากรอกชื่อผู้ตั้งกระทู้");
document.frmComment.username.focus();
return false;
}else if (document.frmComment.code.value=="") {
alert("กรุณากรอกผลลัพธ์ด้านซ้ายมือด้วยครับ");
document.frmComment.code.focus();
return false;
}
}
</script>
<script language="JavaScript" type="text/javascript">
<!-- // --><![CDATA[
var smileys = [
[
[":em23:","em23.gif","laugh"],
[":em24:","em24.gif","angel"],
[":em25:","em25.gif","police"],
[":em26:","em26.gif","wanwan037"],
[":em26:","em26.gif","wanwan043"],
[":em26:","em26.gif","zad"],
[":em29:","em29.gif","wanwan040"],
[":em30:","em30.gif","wanwan026"],
[":em31:","em31.gif","wanwan033"],
[":em32:","em32.gif","wanwan036"],
[":em33:","em33.gif","wanwan041"],
[":em34:","em34.gif","wanwan042"],
[":em35:","em35.gif","wanwan025"],
[":em36:","em36.gif","wanwan030"],
[":em37:","em37.gif","wanwan028"],
[":em38:","em38.gif","wanwan027"],
[":em39:","em39.gif","wanwan032"],
[":em40:","em40.gif","wanwan034"],
[":em41:","em41.gif","wanwan039"],
["em42","em42.gif",""],
[":em43:","em43.gif","wanwan029"],
[":em44:","em44.gif","wanwan038"],
[":em45:","em45.gif","wanwan018"],
[":em46:","em46.gif","wanwan018"],
[":em47:","em47.gif","wanwan018"],
[":em48:","em48.gif","wanwan018"],
[":em49:","em49.gif","wanwan018"],
[":em50:","em50.gif","wanwan018"],
[":em51:","em51.gif","Kiss"]]];
var smileyPopupWindow;
function moreSmileys()
{
var row, i;
if (smileyPopupWindow)
smileyPopupWindow.close();
smileyPopupWindow = window.open("", "add_smileys", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=480,height=220,resizable=no");
smileyPopupWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>');
smileyPopupWindow.document.write('\n\t<head>\n\t\t<title>เพิ่มชุดสัญลักษณ์แสดงอารมณ์</title>\n\t\t<link rel="stylesheet" type="text/css" href="css/style.css" />\n\t</head>');
smileyPopupWindow.document.write('\n\t<body style="margin: 1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0" class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">เลือกชุดสัญลักษณ์แสดงอารมณ์</td></tr>\n\t\t\t<tr class="windowbg"><td align="left">');
for (row = 0; row < smileys.length; row++)
{
for (i = 0; i < smileys[row].length; i++)
{
smileys[row][i][2] = smileys[row][i][2].replace(/"/g, '"');
smileyPopupWindow.document.write('<a href="javascript:void(0);" onclick="window.opener.replaceText(" ' + smileys[row][i][0] + '", window.opener.document.forms.frmComment.message); window.focus(); return false;"><img src="images/emo/' + smileys[row][i][1] + '" alt="' + smileys[row][i][2] + '" title="' + smileys[row][i][2] + '" style="padding: 4px;" border="0" /></a> ');
}
smileyPopupWindow.document.write("<br />");
}
smileyPopupWindow.document.write('</td></tr>\n\t\t\t<tr><td align="center" class="windowbg"><a href="javascript:window.close();\">ปิดหน้าต่าง</a></td></tr>\n\t\t</table>\n\t</body>\n</html>');
smileyPopupWindow.document.close();
}
// ]]>
</script>
<?php
}else{ // ถ้า $step เท่ากับ 2
if ($smc->checkResult("code")) {
date_default_timezone_set('Asia/Bangkok');
$y=date('Y') ;
$m=date('m');
$d=date('d') ;
$H=date('H') ;
$i=date('i');
$s=date('s');
$d="$y$m$d";
$t="$H$i$s";
$ip = $_SERVER['REMOTE_ADDR'];
//$nfame=$_POST['username'];
$mfmail=selections("$_COOKIE[mem_id]","emails");
$message_BBCode=$_POST['message'];
$message=$_POST['message'];
$message=strip_html_tags($message);
$message=EmoBBCode($message);
$message=CheckVulgar($message);
$message=BBCode($message);
$message=stripBBCode($message);
$md="$message";
if(empty($_COOKIE['mem_id'])) {
$status=0;
$nfame=$_POST['username'];
} else {
$status=1;
$nfame=$_COOKIE['user'];
}
///////////นับจำนวนคนเเสดงความคิดเห้นเพื่อ import ///////////////////
$sql = "SELECT COUNT( * ) FROM a_news where q_id=$_GET[id] ";
$result = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_array($result);
$num_product = $row["COUNT( * )"]+1;
ECHO insert2("a_answer,a_name,a_date,a_time,q_id,status,report,ip,number,img_a","'$md','$nfame',$d,$t,$_POST[topicid],'$status','0','$ip','$num_product','$img'","a_news");
echo"<meta http-equiv=refresh content=2;url=readnews.php?id=$_POST[topicid] />";
//echo "<center><div><h3>เก็บส่วนนนี้ลงฐานข้อมูล [edit] สำหรับไว้ตอนแก้ไข</h3>".$message_BBCode."</div></center>";
// echo "<center><h2>ถูกต้องอยากทำไรต่อก็เรื่องของคุณแล้วแหละ</h2></center>";
}else{
echo "<center><h2>คุณบวกเลขไม่ถูกต้องกรุณากลับไปเรียนมาใหม่นะ</h2></center>";
die;
}
?>
<?php
} // end $step=2
// ปิดการติดต่อฐานข้อมูล
mysql_close();
?>
</div>
</div>
<!--black end -->
<!--bot start -->
<!--bot end -->
<? include"footer.php";?>
Tag : PHP, MySQL
Date :
2010-11-14 14:21:18
By :
por
View :
6480
Reply :
3
ตอบได้เลยว่า $gid ไม่มีค่าครับ
Date :
2010-11-14 14:26:58
By :
PlaKriM
ขอบคุณครับท่าน PlaKriM
และอยากจะขอคำแนะนำ อีกสักหน่อยครับ คือผมไปซื้อสคริปเขามาครับ แล้วเขาก็หายไปแล้ว เลยไม่รู้ว่าจะแก้ยังไง เพราะผมก็ไม่เป็น php
อยากทราบว่า ผมจะแก้ใขยังไงครับ ในกรณีที่ ไม่ได้เป็นสมาชิก แล้วโพสต์ทำให้ขึ้นเออเรออย่างนี้ครับ
$gid ควรแก้ใขยังไงครับ
Date :
2010-11-14 14:51:02
By :
por
ไม่แน่ใจนะ
$sql = "select * from member where mem_id=' $gid' ";
ลองดูครับมันจะออกมาแค่ '' มันจะได้ไม่ error นี่แก้ปัญหาเฉพาะหน้าได้แค่นี้แหละ จะให้หายขาดต้องไล่โค๊ดกันเยอะ
Date :
2010-11-14 17:57:24
By :
PlaKriM
Load balance : Server 00