สอบถามเชื่อมต่อกับ File joomla ไม่ได้

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

aepongsak1

สอบถามเชื่อมต่อกับ File joomla ไม่ได้

Post by aepongsak1 » 04/02/2017 6:59 pm

Code: Select all

<?php

require_once '../configuration.php';

$joomlaconfig = new JConfig();

$host = $joomlaconfig->host;
$username = $joomlaconfig->user;
$password = $joomlaconfig->password;
$db = $joomlaconfig->db;

mysql_connect($host, $username, $password) or die('connnect Failed');
mysql_query('set names utf8');
mysql_select_db($db) or die('Select DB Failed');


 ?>

Error


Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\Ex-1-Form\connect.php:12 Stack trace: #0 C:\xampp\htdocs\Ex-1-Form\form.php(3): require_once() #1 {main} thrown in C:\xampp\htdocs\Ex-1-Form\connect.php on line 12

Code: Select all

echo $joomlaconfig;
Recoverable fatal error: Object of class JConfig could not be converted to string in C:\xampp\htdocs\Ex-1-Form\connect.php on line 7

User avatar
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
Posts: 22585
Joined: 22/09/2008 6:18 pm
Contact:

Re: สอบถามเชื่อมต่อกับ File joomla ไม่ได้

Post by mindphp » 04/02/2017 8:07 pm

ลอง print_r($joomlaconfig)
ดูว่ามีค่าจาก Joomla เข้ามาไหมครับ
ติดตาม 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

Pongsak Keaononpho
PHP Newbie
PHP Newbie
Posts: 2
Joined: 02/02/2017 6:48 pm

Re: สอบถามเชื่อมต่อกับ File joomla ไม่ได้

Post by Pongsak Keaononpho » 05/02/2017 2:07 pm

mindphp wrote:ลอง print_r($joomlaconfig)
ดูว่ามีค่าจาก Joomla เข้ามาไหมครับ
JConfig Object ( [offline] => 0 [offline_message] => This site is down for maintenance.
Please check back again soon. [display_offline_message] => 1 [offline_image] => [sitename] => m039mindphp [editor] => tinymce [captcha] => 0 [list_limit] => 20 [access] => 1 [debug] => 0 [debug_lang] => 0 [dbtype] => mysqli [host] => localhost [user] => root [password] => [db] => m039 [dbprefix] => tx4th_ [live_site] => [secret] => mGZ848GMFKFFDiVC [gzip] => 0 [error_reporting] => default [helpurl] => https://help.joomla.org/proxy/index.php ... r}:{keyref} [ftp_host] => [ftp_port] => [ftp_user] => [ftp_pass] => [ftp_root] => [ftp_enable] => 0 [offset] => UTC [mailonline] => 1 [mailer] => mail [mailfrom] => m039.ติดต่อทาง pm [fromname] => m039mindphp [sendmail] => /usr/sbin/sendmail [smtpauth] => 0 [smtpuser] => [smtppass] => [smtphost] => localhost [smtpsecure] => none [smtpport] => 25 [caching] => 0 [cache_handler] => file [cachetime] => 15 [cache_platformprefix] => 0 [MetaDesc] => m039mindphp [MetaKeys] => [MetaTitle] => 1 [MetaAuthor] => 1 [MetaVersion] => 0 [robots] => [sef] => 1 [sef_rewrite] => 0 [sef_suffix] => 0 [unicodeslugs] => 0 [feed_limit] => 10 [feed_email] => none [log_path] => C:\xampp\htdocs\m039mindphp\administrator/logs [tmp_path] => C:\xampp\htdocs\m039mindphp/tmp [lifetime] => 15 [session_handler] => database )
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\m039mindphp\Ex-1-Form\connect.php:14 Stack trace: #0 C:\xampp\htdocs\m039mindphp\Ex-1-Form\form.php(3): require_once() #1 {main} thrown in C:\xampp\htdocs\m039mindphp\Ex-1-Form\connect.php on line 14

Pongsak Keaononpho
PHP Newbie
PHP Newbie
Posts: 2
Joined: 02/02/2017 6:48 pm

Re: สอบถามเชื่อมต่อกับ File joomla ไม่ได้

Post by Pongsak Keaononpho » 05/02/2017 2:08 pm

JConfig Object ( [offline] => 0 [offline_message] => This site is down for maintenance.
Please check back again soon. [display_offline_message] => 1 [offline_image] => [sitename] => m039mindphp [editor] => tinymce [captcha] => 0 [list_limit] => 20 [access] => 1 [debug] => 0 [debug_lang] => 0 [dbtype] => mysqli [host] => localhost [user] => root [password] => [db] => m039 [dbprefix] => tx4th_ [live_site] => [secret] => mGZ848GMFKFFDiVC [gzip] => 0 [error_reporting] => default [helpurl] => https://help.joomla.org/proxy/index.php ... r}:{keyref} [ftp_host] => [ftp_port] => [ftp_user] => [ftp_pass] => [ftp_root] => [ftp_enable] => 0 [offset] => UTC [mailonline] => 1 [mailer] => mail [mailfrom] => m039.ติดต่อทาง pm [fromname] => m039mindphp [sendmail] => /usr/sbin/sendmail [smtpauth] => 0 [smtpuser] => [smtppass] => [smtphost] => localhost [smtpsecure] => none [smtpport] => 25 [caching] => 0 [cache_handler] => file [cachetime] => 15 [cache_platformprefix] => 0 [MetaDesc] => m039mindphp [MetaKeys] => [MetaTitle] => 1 [MetaAuthor] => 1 [MetaVersion] => 0 [robots] => [sef] => 1 [sef_rewrite] => 0 [sef_suffix] => 0 [unicodeslugs] => 0 [feed_limit] => 10 [feed_email] => none [log_path] => C:\xampp\htdocs\m039mindphp\administrator/logs [tmp_path] => C:\xampp\htdocs\m039mindphp/tmp [lifetime] => 15 [session_handler] => database )
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\m039mindphp\Ex-1-Form\connect.php:14 Stack trace: #0 C:\xampp\htdocs\m039mindphp\Ex-1-Form\form.php(3): require_once() #1 {main} thrown in C:\xampp\htdocs\m039mindphp\Ex-1-Form\connect.php on line 14

thatsawan
PHP VIP Members
PHP VIP Members
Posts: 19916
Joined: 31/03/2014 10:02 am
Contact:

Re: สอบถามเชื่อมต่อกับ File joomla ไม่ได้

Post by thatsawan » 05/02/2017 3:08 pm

ปัญหามาจาก เขียนใน php 7 ต้องแก้ไข connect ค่ะ

หรือจะดักด้วยตัวแปล เช็คเวอร์ชั่น php ก่อนก็ได้ค่ะ

Code: Select all

phpversion(); 

Code: Select all

$con = mysqli_connect("localhost","my_user","my_password","my_db");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  } 

Post Reply

Return to “Programming - PHP”

Users browsing this forum: No registered users and 19 guests