PHP รับค่ามาจาก $_GET อยากให้บันทึกลง Mysql

เริ่มโดย bladesuper, 24 กันยายน 2010, 10:33:33

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

bladesuper

<?php
  $a 
fopen("db.txt","a+");
  
$d "".date("d M Y H:i:s"mktime(date("H")+6date("i")+1date("s")+10date("m")+0  date("d")+0date("Y")+0))."\r\n";

  
fputs ($a,$d);
  
fputs ($a,"Rainfall = $rainfall "  );
  
fputs ($a," ");

  
fputs ($a,"\r\n");
  
fclose($a);

  echo(
"Server receive Rainfall = $rainfall ");
?>

มันบันทึกเป็น txt ไฟล์ อยากให้มันบันทึกลง MySQL เลยได้ไหมครับ

fkungkub

อ้างถึงจาก: bladesuper ใน 24 กันยายน 2010, 10:33:33
<?php
  $a 
fopen("db.txt","a+");
  
$d "".date("d M Y H:i:s"mktime(date("H")+6date("i")+1date("s")+10date("m")+0  date("d")+0date("Y")+0))."\r\n";

  
fputs ($a,$d);
  
fputs ($a,"Rainfall = $rainfall "  );
  
fputs ($a," ");

  
fputs ($a,"\r\n");
  
fclose($a);

  echo(
"Server receive Rainfall = $rainfall ");
?>

มันบันทึกเป็น txt ไฟล์ อยากให้มันบันทึกลง MySQL เลยได้ไหมครับ
แบบนี้ป่าวครับ
              $a=$_GET['testa'];
            $sql="insert into ชื่อตาราง values($a);
            $query=mysql_query($sql);

bladesuper

อ้างถึงจาก: fkungkub ใน 24 กันยายน 2010, 10:46:00
อ้างถึงจาก: bladesuper ใน 24 กันยายน 2010, 10:33:33
<?php
  $a 
fopen("db.txt","a+");
  
$d "".date("d M Y H:i:s"mktime(date("H")+6date("i")+1date("s")+10date("m")+0  date("d")+0date("Y")+0))."\r\n";

  
fputs ($a,$d);
  
fputs ($a,"Rainfall = $rainfall "  );
  
fputs ($a," ");

  
fputs ($a,"\r\n");
  
fclose($a);

  echo(
"Server receive Rainfall = $rainfall ");
?>

มันบันทึกเป็น txt ไฟล์ อยากให้มันบันทึกลง MySQL เลยได้ไหมครับ
แบบนี้ป่าวครับ
              $a=$_GET['testa'];
            $sql="insert into ชื่อตาราง values($a);
            $query=mysql_query($sql);

ใส่่ตรงไหนอ่ะครับ

yoyokung

#3
จะรับค่าลง Database ต้องมีดาตาเบสด้วยนะครับ


<?php
$db 
mysql_connect("MySQL_server""MySQL_user""MySQL_pass") OR die ('Cant connect to the database Client ');
mysql_select_db($host['Database_name'], $db);


$new_insert mysql_query("INSERT INTO `TABLE_NAME` (`FIELD_NAME`,`FIELD_NAME_2`) VALUES ( '".$GET['GET_VALUE']."','".$GET['GET_VALUE_2']."')") or die(mysql_error());
?>



[direct=http://loop.in.th/demo/game_query/index.php]ขาย ฐานข้อมูล Flash Game กว่า 25,000 เกมส์[/direct] 5,000 บาท

[direct=http://www.ฉันรักเธอ.com]ฉันรักเธอ[/direct] [direct=http://www.เที่ยวไทย.com]เที่ยวไทย[/direct]

[direct=http://asiangoodjobs.com/learn/php/]สอนดึงเว็บ[/direct] 30 ชั่วโมง / 5,000 บาท สุดยอดมาก
[direct=http://asiangoodjobs.com/learn/php/]สอนดูดเว็บ[/direct] 30 ชั่วโมง / HTML , CSS , jQuery , PHP


gootooyoo

ลองดูวิธีการติดต่อฐานข้อมูลครับ พี่จาก google
ขวากหนาม ที่เราต้องข้ามผ่าน ถึงจะเจ็บก็จะไป (\◣_◢/)  [direct=http://gootooyoo.blogspot.com] [/direct]
[direct=http://gootooyoo.blog.com] ❤ [direct=http://free-icons.blogspot.com] ❤  [direct=http://goo-dog.blogspot.com]❤