 |
Up ขึน Host แล้วค่าที่ส่งมันหายครับ รบกวนช่วยดูให้ด้วยครับ |
|
 |
|
|
 |
 |
|
พอ submit แล้วค่า qid หาย มันจึงไม่รู้จะไป
selec where เท่ากับค่า qid ตัวไหน
**ที่หน้าไฟล์ post.php ***กระทู้รวม
<a href="javascript:new_window('detail.php?qid=<? echo $row["qid"]?>')"><? echo $row["qname"]?></a>
ลิง้ค์จากหน้ารวมกระทู้มาตอนแลก ค่า qid จะส่งค่ามาได้ และมันก็สามารถโช้ว์ หัวข้อกระทู้จากฐานข้อมูลได้
แต่ถ้าตอบกระทู้และ submit แล้วปรากฎว่า ค่า qid หาย มันจึงไป select where ไม่ได้
**ที่หน้าไฟล์ detail.php **ตอบกระทู้
<?
include "connect.php";
include "function1.php";
$ddd=$_POST[submit];
if(trim($ddd)=="บันทึก"){
$sql="select * from tanswer where adate='".trim($_POST['adate'])."' and atime='".trim($_POST['atime'])."' and qid='".$qid."' ";
$result=mysql_query($sql);
$numr=mysql_num_rows($result);
if($numr==0){
$sql=" INSERT INTO tanswer(qid,apost,adetail,adate,aip,atime)
VALUES
('".trim($_POST['qid'])."','".trim($_POST['apost'])."' ,'".trim($_POST['adetail'])."','".trim($_POST['adate'])."','".trim($_POST['aip'])."','".trim($_POST['atime'])."')";
mysql_query($sql); //$result=odbc_exec($conn,$sql);
}
}
?>
แต่ถ้าในเครื่องคอม ไม่ต้องใช้ $_GET หรือ $_POST มารับค่า
มันสามารถทำงานได้หมดไม่มีปัญหา
พอ Up ขึ้น Host แล้วมันไม่ยอมส่งค่า ก็เลยต้องมาใช้ $_GET หรือ $_POST
ก็เลยต้องมาไล่หาค่า qid
***นี้คือโค๊ดที่ใช้ select หัวข้อกระทู้มาโชว์
<?
//$sql = "select * from tquestion where qid ='".$qid."' "; //ถ้าใช้บรรทัดนี้ในคอม จะสามารถทำงานได้หมด โชว์หัวข้อกระทู้ พร้อม คำตอบ ขอคนที่ submit ได้ แต่บน Host ไม่โชว์
$sql = "select * from tquestion where qid ='".trim($_GET['qid'])."' "; //ถ้าใช้บรรทัดนี้บน Host ลิ้งจากหน้ารวมกระทู้มาโชว์หน้า detail.php ได้
$re=mysql_query($sql);
$row=mysql_fetch_array($re);
?>
***นี้คือโค๊ดที่ใช้ select คำตอบกระทู้มาโชว์
<?
$sql="select * from tanswer where qid ='".trim($_GET['qid'])."' Order by adate,atime ";ใช้ตัวนี้ Host ทำงานได้
//$sql="select * from tanswer where qid ='".$qid."' Order by adate,atime ";ใช้ตัวนี้คอมทำงานได้
$re=mysql_query($sql);
while ($row=mysql_fetch_array($re)){
?>
รบกวนด้วยครับ
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2011-09-23 13:43:10 |
By :
tongchimlang |
View :
5562 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนด้วยครับ
นั่งแก้ นั่งไล่หา มาหลายวันแล้ว
ยังไม่ได้เลยครับ
|
 |
 |
 |
 |
Date :
2011-09-23 15:54:18 |
By :
tongchimlang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ $_GET หรือ $_POST ถูกต้องแล้วครับ แต่ถ้าไม่อยากแก้ก็ใช้ตัวนี้ครับ
Code (PHP)
<?
//*** Register Global =On/Off Function ***//
$phpVersion = phpversion();
list($v_Upper,$v_Major,$v_Minor) = explode(".",$phpVersion);
if (($v_Upper == 4 && $v_Major < 1) || $v_Upper < 4) {
$_FILES = $HTTP_POST_FILES;
$_ENV = $HTTP_ENV_VARS;
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_COOKIE = $HTTP_COOKIE_VARS;
$_SERVER = $HTTP_SERVER_VARS;
$_SESSION = $HTTP_SESSION_VARS;
$_FILES = $HTTP_POST_FILES;
}
if (!ini_get('register_globals')) {
while(list($key,$value)=each($_FILES)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_ENV)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_GET)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_POST)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_COOKIE)) $GLOBALS[$key]=$value;
while(list($key,$value)=each($_SERVER)) $GLOBALS[$key]=$value;
while(list($key,$value)=@each($_SESSION)) $GLOBALS[$key]=$value;
foreach($_FILES as $key => $value){
$GLOBALS[$key]=$_FILES[$key]['tmp_name'];
foreach($value as $ext => $value2){
$key2 = $key."_".$ext;
$GLOBALS[$key2]=$value2;
}
}
}
?>
โดยทำเป็นไฟล์ Include แล้วแทรกไว้ทุกไฟล์ที่เรียกใช้ครับ
Go to : PHP register_global = On/Off
|
 |
 |
 |
 |
Date :
2011-09-24 07:04:30 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|