การใช้ iis กับ mysql
Moderator: mindphp
- buatong
- PHP Jr. Member
- Posts: 20
- Joined: 01/01/1970 7:00 am
การใช้ iis กับ mysql
ตอนแรกใช้ server1 โดยลง appserv ก็ run php connect mysql ได้ปกติ
พอย้าย code มาไว้ที่ server2 ที่มี iis และ php อยู่ก่อนแล้ว ก็เลยต้องแก้ config ใหม่ ส่วน mysql ก็ลงโดยใช้ appserv ตามปกติ (ลงเฉพาะ mysql) อยากทราบว่า ต้องแก้ config อะไรบ้างค่ะ อย่างไรบ้าง เพราะตอนนี้ run code php ได้ (จากเมื่อก่อนขึ้นหน้า blank) แต่ไม่ connect กับฐานข้อมูลให้ค่ะ และพอลองรันตัว code ด้านล่าง เพื่อ check ดูว่า connect ได้ไหม ก็ขึ้นแต่หน้าว่างค่ะ
<?PHPsession_start();ob_start(); class Data_Mysql{ var $result; var $sql; var $querysql; var $num; var $massage_send; var $massage_error; var $Hostname="localhost";#Hosting of Database System var $Uname="root";#Username Database System var $Pname=""; #Password Database System var $Dname="dbname"; #Database Name System function ConnectionMysql($user,$pass,$idcard,$posit,$depart,$gover){ if($this->Conn_mysql()){ if($this->Conn_database()){ if($this->SQLS_Member($user,$pass,$idcard,$posit,$depart,$gover)){ #if($this->SQLS_Menu($user,$pass)){ $this->massage_send=1; #}else{ #$this->massage_send="<div align='center' style='color:#FF6600'>ไม่พบสิทธิ์ขอท่านจากการเรียกใช้ของระบบ กรุณาติดต่อเจ้าหน้าที่ผู้เกี่ยวข้อง</div>"; #} }else{ $this->massage_send="<div align='center' style='color:#FF6600'>ท่านกรอก Username หรือ Password ไม่ถูกต้อง กรุณาตรวจสอบข้อมูลอีกครั้ง</div>"; } }else{ $this->massage_send="ไม่สามารถใช้ฐานข้อมูล Mysql ได้"; } }else{ $this->massage_send="ไม่สามารถเชื่อมต่อกับระบบฐานข้อมูล Mysql ได้"; } return $this->massage_send; } function Conn_mysql(){ $this->result=mysql_connect($this->Hostname,$this->Uname,$this->Pname); return $this->result; } function Conn_database(){ $this->result=mysql_select_db($this->Dname,$this->Conn_mysql()); return $this->result; } function SQLS_Member($user,$pass,$idcard,$posit,$depart,$gover){ $this->sql=" SELECT"; $this->sql.=" A.intronameID";#0 $this->sql.=" ,A.username";#1 $this->sql.=" ,A.password";#2 $this->sql.=" ,A.orgID";#3 $this->sql.=" ,A.ruleid";#4 $this->sql.=" ,B.NAME_TH";#5 $this->sql.=" ,B.NAME_EN";#6 $this->sql.=" ,C.SERIAL_NO";#7 $this->sql.=" ,C.ORG_CODE";#8 $this->sql.=" ,C.ORG_LEVEL";#9 $this->sql.=" ,C.ORG_NAME";#10 $this->sql.=" ,C.FULL_NAME";#11 $this->sql.=" ,C.ORG_ABBR_NAME";#12 $this->sql.=" ,C.FULL_IN_ABBR_NAME";#13 $this->sql.=" ,C.ROOT_LEVEL1";#14 $this->sql.=" ,C.ROOT_LEVEL2";#15 $this->sql.=" ,C.ROOT_LEVEL3";#16 $this->sql.=" ,C.ROOT_LEVEL4";#17 $this->sql.=" ,C.ROOT_LEVEL5"; #18 $this->sql.=" FROM member A"; $this->sql.=" INNER JOIN introname B"; $this->sql.=" ON intronameID=B.INID"; $this->sql.=" INNER JOIN org_level C"; $this->sql.=" ON A.orgID=C.SERIAL_NO"; $this->sql.=" WHERE A.username='$user' AND A.password='$pass' AND C.STATUS='A' AND A.idcardID='$idcard' AND C.ROOT_LEVEL1='$gover' AND C.ROOT_LEVEL2='$depart' AND C.ORG_CODE='$posit' "; $this->result=mysql_db_query($this->Dname,$this->sql); if($Member_Value=mysql_fetch_array($this->result)) { $_SESSION['session_innameid']=$Member_Value[0]; $_SESSION['session_user']=$Member_Value[1]; $_SESSION['session_pass']=$Member_Value[2]; $_SESSION['session_orgid']=$Member_Value[3]; $_SESSION['session_rule']=$Member_Value[4]; $_SESSION['session_intro_name']=$Member_Value[5]; $_SESSION['session_org_serial']=$Member_Value[6]; $_SESSION['session_org_code']=$Member_Value[7]; $_SESSION['session_org_level']=$Member_Value[8]; $_SESSION['session_org_name']=$Member_Value[10]; $_SESSION['session_org_name_full']=$Member_Value[11]; $_SESSION['session_org_abbr_name']=$Member_Value[12]; $_SESSION['session_org_abbr_name_full']=$Member_Value[13]; $_SESSION['session_root_level_1']=$Member_Value[14]; $_SESSION['session_root_level_2']=$Member_Value[15]; $_SESSION['session_root_level_3']=$Member_Value[16]; $_SESSION['session_root_level_4']=$Member_Value[17]; $_SESSION['session_root_level_5']=$Member_Value[18]; $_SESSION['session_signin']=true; $this->result=true; }else{ session_unregister($_SESSION['session_user']); session_unregister($_SESSION['session_pass']); session_unregister($_SESSION['session_signin']); $this->result=false; } return $this->result; } function SQLS_FormApp($user,$pass){ $this->sql="SELECT B.name,B.module FROM member A INNER JOIN B ON A.id=B.memberid WHERE A.username='$user' AND A.password='$pass'"; $this->result=mysql_db_query($this->Dname,$this->sql); if($FormApp_Value=mysql_fetch_array($this->result)) { $_SESSION['session_formapp']=$FormApp_Value[1]; $this->result=true; }else{ session_unregister($_SESSION['session_formapp']); $this->result=false; } return $this->result; } function SQLS_Menu($rule){ $this->sql="SELECT distinct B.menu_name,B.menu_module,B.menu_file FROM authen A INNER JOIN menu B ON A.menuid=B.menu_id WHERE A.rule_id=$rule"; $this->result = mysql_db_query($this->Dname,$this->sql); return $this->result; } function SQLS_SubMenu($rule){ $this->sql="SELECT B.submenu_name,B.submenu_file FROM authen A INNER JOIN submenu B ON A.submenuid=B.submenuid WHERE A.rule_id=$rule"; $this->result = mysql_db_query($this->Dname,$this->sql); return $this->result; } }# End Class $fc_database=new Data_Mysql();?>
พอย้าย code มาไว้ที่ server2 ที่มี iis และ php อยู่ก่อนแล้ว ก็เลยต้องแก้ config ใหม่ ส่วน mysql ก็ลงโดยใช้ appserv ตามปกติ (ลงเฉพาะ mysql) อยากทราบว่า ต้องแก้ config อะไรบ้างค่ะ อย่างไรบ้าง เพราะตอนนี้ run code php ได้ (จากเมื่อก่อนขึ้นหน้า blank) แต่ไม่ connect กับฐานข้อมูลให้ค่ะ และพอลองรันตัว code ด้านล่าง เพื่อ check ดูว่า connect ได้ไหม ก็ขึ้นแต่หน้าว่างค่ะ
<?PHPsession_start();ob_start(); class Data_Mysql{ var $result; var $sql; var $querysql; var $num; var $massage_send; var $massage_error; var $Hostname="localhost";#Hosting of Database System var $Uname="root";#Username Database System var $Pname=""; #Password Database System var $Dname="dbname"; #Database Name System function ConnectionMysql($user,$pass,$idcard,$posit,$depart,$gover){ if($this->Conn_mysql()){ if($this->Conn_database()){ if($this->SQLS_Member($user,$pass,$idcard,$posit,$depart,$gover)){ #if($this->SQLS_Menu($user,$pass)){ $this->massage_send=1; #}else{ #$this->massage_send="<div align='center' style='color:#FF6600'>ไม่พบสิทธิ์ขอท่านจากการเรียกใช้ของระบบ กรุณาติดต่อเจ้าหน้าที่ผู้เกี่ยวข้อง</div>"; #} }else{ $this->massage_send="<div align='center' style='color:#FF6600'>ท่านกรอก Username หรือ Password ไม่ถูกต้อง กรุณาตรวจสอบข้อมูลอีกครั้ง</div>"; } }else{ $this->massage_send="ไม่สามารถใช้ฐานข้อมูล Mysql ได้"; } }else{ $this->massage_send="ไม่สามารถเชื่อมต่อกับระบบฐานข้อมูล Mysql ได้"; } return $this->massage_send; } function Conn_mysql(){ $this->result=mysql_connect($this->Hostname,$this->Uname,$this->Pname); return $this->result; } function Conn_database(){ $this->result=mysql_select_db($this->Dname,$this->Conn_mysql()); return $this->result; } function SQLS_Member($user,$pass,$idcard,$posit,$depart,$gover){ $this->sql=" SELECT"; $this->sql.=" A.intronameID";#0 $this->sql.=" ,A.username";#1 $this->sql.=" ,A.password";#2 $this->sql.=" ,A.orgID";#3 $this->sql.=" ,A.ruleid";#4 $this->sql.=" ,B.NAME_TH";#5 $this->sql.=" ,B.NAME_EN";#6 $this->sql.=" ,C.SERIAL_NO";#7 $this->sql.=" ,C.ORG_CODE";#8 $this->sql.=" ,C.ORG_LEVEL";#9 $this->sql.=" ,C.ORG_NAME";#10 $this->sql.=" ,C.FULL_NAME";#11 $this->sql.=" ,C.ORG_ABBR_NAME";#12 $this->sql.=" ,C.FULL_IN_ABBR_NAME";#13 $this->sql.=" ,C.ROOT_LEVEL1";#14 $this->sql.=" ,C.ROOT_LEVEL2";#15 $this->sql.=" ,C.ROOT_LEVEL3";#16 $this->sql.=" ,C.ROOT_LEVEL4";#17 $this->sql.=" ,C.ROOT_LEVEL5"; #18 $this->sql.=" FROM member A"; $this->sql.=" INNER JOIN introname B"; $this->sql.=" ON intronameID=B.INID"; $this->sql.=" INNER JOIN org_level C"; $this->sql.=" ON A.orgID=C.SERIAL_NO"; $this->sql.=" WHERE A.username='$user' AND A.password='$pass' AND C.STATUS='A' AND A.idcardID='$idcard' AND C.ROOT_LEVEL1='$gover' AND C.ROOT_LEVEL2='$depart' AND C.ORG_CODE='$posit' "; $this->result=mysql_db_query($this->Dname,$this->sql); if($Member_Value=mysql_fetch_array($this->result)) { $_SESSION['session_innameid']=$Member_Value[0]; $_SESSION['session_user']=$Member_Value[1]; $_SESSION['session_pass']=$Member_Value[2]; $_SESSION['session_orgid']=$Member_Value[3]; $_SESSION['session_rule']=$Member_Value[4]; $_SESSION['session_intro_name']=$Member_Value[5]; $_SESSION['session_org_serial']=$Member_Value[6]; $_SESSION['session_org_code']=$Member_Value[7]; $_SESSION['session_org_level']=$Member_Value[8]; $_SESSION['session_org_name']=$Member_Value[10]; $_SESSION['session_org_name_full']=$Member_Value[11]; $_SESSION['session_org_abbr_name']=$Member_Value[12]; $_SESSION['session_org_abbr_name_full']=$Member_Value[13]; $_SESSION['session_root_level_1']=$Member_Value[14]; $_SESSION['session_root_level_2']=$Member_Value[15]; $_SESSION['session_root_level_3']=$Member_Value[16]; $_SESSION['session_root_level_4']=$Member_Value[17]; $_SESSION['session_root_level_5']=$Member_Value[18]; $_SESSION['session_signin']=true; $this->result=true; }else{ session_unregister($_SESSION['session_user']); session_unregister($_SESSION['session_pass']); session_unregister($_SESSION['session_signin']); $this->result=false; } return $this->result; } function SQLS_FormApp($user,$pass){ $this->sql="SELECT B.name,B.module FROM member A INNER JOIN B ON A.id=B.memberid WHERE A.username='$user' AND A.password='$pass'"; $this->result=mysql_db_query($this->Dname,$this->sql); if($FormApp_Value=mysql_fetch_array($this->result)) { $_SESSION['session_formapp']=$FormApp_Value[1]; $this->result=true; }else{ session_unregister($_SESSION['session_formapp']); $this->result=false; } return $this->result; } function SQLS_Menu($rule){ $this->sql="SELECT distinct B.menu_name,B.menu_module,B.menu_file FROM authen A INNER JOIN menu B ON A.menuid=B.menu_id WHERE A.rule_id=$rule"; $this->result = mysql_db_query($this->Dname,$this->sql); return $this->result; } function SQLS_SubMenu($rule){ $this->sql="SELECT B.submenu_name,B.submenu_file FROM authen A INNER JOIN submenu B ON A.submenuid=B.submenuid WHERE A.rule_id=$rule"; $this->result = mysql_db_query($this->Dname,$this->sql); return $this->result; } }# End Class $fc_database=new Data_Mysql();?>
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26577
- Joined: 22/09/2008 6:18 pm
- Contact:
ลงเพียงอย่าง เดียวโหลด mysql มาลงเองดีกว่าครับ
อย่างแรกให้ เช็ค ว่า รัน php ได้ปกติ หรือเปล่า
ถ้าได้ ลอง เช็ค ว่า เป็น เวอร์ชั่นอะไร ถ้าเวอร์ชั่น หลังจาก 4.3 มันจะไม่มี ส่วนของการติดต่อกับ mysql มาให้ เราต้องลงเพิ่มเอาเอง
อย่างแรกให้ เช็ค ว่า รัน php ได้ปกติ หรือเปล่า
ถ้าได้ ลอง เช็ค ว่า เป็น เวอร์ชั่นอะไร ถ้าเวอร์ชั่น หลังจาก 4.3 มันจะไม่มี ส่วนของการติดต่อกับ mysql มาให้ เราต้องลงเพิ่มเอาเอง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26577
- Joined: 22/09/2008 6:18 pm
- Contact:
ลองเช็ค ว่า ใน โฟสเดอ extensions มี php_mysql.dll หรือยัง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26577
- Joined: 22/09/2008 6:18 pm
- Contact:
ลองเช็ค ตามที่บอกหรือยังครับ เพราะ อาจจะมีอยู่ แล้ว แต่ ยังไม่ได้ เปิดใช้งานก็ ได้ แต่ถ้าเช็ค แล้วไม่เจอ ก็ ต้องโหลดมาเพิ่ม เองครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
- buatong
- PHP Jr. Member
- Posts: 20
- Joined: 01/01/1970 7:00 am
PHP มีอยู่แล้วค่ะ เป็น Version 5.1.6 เช็คแล้ว run php ได้ แต่ connect mysql ไม่ได้ ลองทำตาม www.t2.tph.go.th/php.html และ http://www.cmsthailand.com/docs/iis_php ... admin.html ใช่วิธีนี้หรือเปล่า ลองทำแล้วก็ไม่เกิด...เศร้า
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26577
- Joined: 22/09/2008 6:18 pm
- Contact:
o Browser แสดง แบบ รูปสุดท้าย แสดงว่าเราทำถูกแล้ว คับ
วิธีการ Config ให้ PHP สามารถใช้ MySQL ได้
* ให้เราทำการ แก้ไขแฟ้ม php.ini ตรงบรรทัดที่เขียนว่า
o ;extension=php_mysql.dll ให้เรานำเครื่องหมาย ; ที่อยู่ข้างหน้าบรรทัดออก แล้วบันทึกลงข้อมูล
o ให้เราทำการ Copy แฟ้มข้อมูล ชื่อ php_mysql.dll ที่อยู่ใน Directory ของ \php\ext ไปไว้ที่ \Windows\System32
o ให้เราทำการ Copy แฟ้มข้อมูล ชื่อ libmysql.dll ที่อยู่ใน Directory ของ \php ไปไว้ที่ \Windows\System32
ตามนี้ ช่าย มั๊ยครับ แล้ว restart IIS หรือยังครับ
วิธีการ Config ให้ PHP สามารถใช้ MySQL ได้
* ให้เราทำการ แก้ไขแฟ้ม php.ini ตรงบรรทัดที่เขียนว่า
o ;extension=php_mysql.dll ให้เรานำเครื่องหมาย ; ที่อยู่ข้างหน้าบรรทัดออก แล้วบันทึกลงข้อมูล
o ให้เราทำการ Copy แฟ้มข้อมูล ชื่อ php_mysql.dll ที่อยู่ใน Directory ของ \php\ext ไปไว้ที่ \Windows\System32
o ให้เราทำการ Copy แฟ้มข้อมูล ชื่อ libmysql.dll ที่อยู่ใน Directory ของ \php ไปไว้ที่ \Windows\System32
ตามนี้ ช่าย มั๊ยครับ แล้ว restart IIS หรือยังครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- Similar Topics
- Replies
- Views
- Last post
-
-
ขอความช่วยเหลือ การใช้ php import CSV to mysql ครับ
by mekhong » 06/06/2013 5:15 pm » in Programming - PHP - 4 Replies
- 2155 Views
-
Last post by mekhong
07/06/2013 9:54 am
-
-
-
การใช้ ZF & Mysql กับ ภาษาไทย Zend Framework
by zend_framework » 17/04/2011 5:26 pm » in Share Knowledge - 0 Replies
- 6145 Views
-
Last post by zend_framework
17/04/2011 5:26 pm
-
-
-
อัพเกรด Mysql Ubuntu จาก MySQL 5.5 เป็น MySQL 5.7
by mindphp » 12/06/2016 5:57 pm » in Linux - Web Server - 1 Replies
- 1294 Views
-
Last post by mindphp
12/06/2016 5:58 pm
-
-
-
ปัญหา MySQL is running but PID file could not be found พบบ่อยกับ Innodb ของ Mysql เพราะพื้นที่ไม่พอ
by mindphp » 13/11/2016 9:00 pm » in Linux - Web Server - 2 Replies
- 1378 Views
-
Last post by mindphp
09/03/2017 8:21 pm
-
-
-
ปรับเวลาใน Mysql เพิ่ม จำนวนวันใน mysql ตามต้องการ ด้วย DATE_ADD
by mindphp » 01/07/2011 12:04 am » in SQL - Database - 0 Replies
- 2379 Views
-
Last post by mindphp
01/07/2011 12:04 am
-
-
-
ปัญหา MySQL unknown column 'password_last_changed' หลังการอัพเกรด MySQL เป็นเวอร์ชั่น 5.7
by mindphp » 13/06/2016 5:42 pm » in SQL - Database - 1 Replies
- 1317 Views
-
Last post by mindphp
13/06/2016 5:44 pm
-
-
-
วิธีการหา Error ของการ Insert ข้อมูลลงฐานข้อมูล Mysql โดยใช้ Mysql
by Patipat » 17/06/2019 5:42 pm » in SQL Knowledge - 0 Replies
- 2316 Views
-
Last post by Patipat
17/06/2019 5:42 pm
-
-
-
วิธีการใช้งาน MySql Workbench สร้าง ER สร้างตาราง, ควบคุม Mysql Server ทั้ง Host
by samsonnaze3 » 03/04/2012 1:45 pm » in Share Knowledge - 21 Replies
- 30535 Views
-
Last post by samsonnaze3
03/04/2012 2:57 pm
-
Who is online
Users browsing this forum: No registered users and 10 guests