Home Backend Development PHP Tutorial 关于dsn的有关问题

关于dsn的有关问题

Jun 13, 2016 am 10:38 AM
port pwd quot user

关于dsn的问题
最近在codeigniter中使用dsn进行数据库连接,但是不管端口号改成什么总是能够连接成功,而修改用户名,密码或ip地址的话就会出现连接失败的问题,下面是我的代码

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->    function get_remote_dblist($ip, $port, $user, $pwd) {        $dsn = "mysql://$user:$pwd@$ip:$port";        $newDB = $this->load->database ( $dsn , TRUE );return $newDB->version();}
Copy after login

烦请各位前辈指点下

------解决方案--------------------
CI的官方文档中并未提及DSN中主机名可以附加端口号。有一个折衷的方法你可以试试
PHP code
$dsn = "mysql://{$user}:{$pwd}@{$ip}/?port={$port}";<div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does pwd mean in linux What does pwd mean in linux Jul 10, 2023 pm 04:23 PM

pwd in Linux means a common command in Linux. It is a command commonly used by Linux system administrators and ordinary users. It can help users quickly find the current directory, facilitate users to better manage files and directories, and can also help administrators and Users can quickly locate certain specific directories or files to better manage the Linux system.

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Nintendo Switch 2 rumored to get ports of Assassin\'s Creed Shadows and previous entries in the series Nintendo Switch 2 rumored to get ports of Assassin\'s Creed Shadows and previous entries in the series Aug 14, 2024 pm 12:36 PM

Last week, Paul Gele, a known gaming insider, shared that the upcoming Nintendo Switch 2 will get major third-party AAA ports at launch. This is something to look forward to because the first-gen gaming handheld didn't get any AAA titles at launch. B

How to solve the problem of docker mounting directory permissions How to solve the problem of docker mounting directory permissions Feb 29, 2024 am 10:04 AM

In Docker, the permission problem of the mounting directory can usually be solved by the following method: adding permission-related options when using the -v parameter to specify the mounting directory. You can specify the permissions of the mounted directory by adding: ro or :rw after the mounted directory, indicating read-only and read-write permissions respectively. For example: dockerrun-v/host/path:/container/path:roimage_name Define the USER directive in the Dockerfile to specify the user running in the container to ensure that operations inside the container comply with permission requirements. For example: FROMimage_name#CreateanewuserRUNuseradd-ms/bin/

How to use linux pwd command How to use linux pwd command May 18, 2023 am 08:40 AM

In Linux, use the pwd command to view the full path of the "current working directory". Simply put, whenever you operate in the terminal, you will have a current working directory. When the current location is uncertain, pwd is used to determine the exact location of the current directory in the file system. 1. Command format: pwd[option]2. Command function: View the full path of the "current working directory" 3. Commonly used parameters: Generally without any parameters, if the directory is a link: Format: pwd-p displays the actual path instead of using the link path. 4. Commonly used examples: Example 1: Use the pwd command to view the full path of the default working directory Command: pwd output: Copy the code The code is as follows: [root@localh

What does pwd mean in linux? What does pwd mean in linux? Feb 23, 2023 am 10:14 AM

In Linux, the full name of pwd is print working directory, which means printing the current working directory; the function of the pwd command is to display the current directory, and the syntax is "pwd [option]". The pwd command is mainly used to view the absolute path of the current directory when the current location is not certain.

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 Jun 13, 2016 am 10:15 AM

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。

图片消失怎么解决 图片消失怎么解决 Apr 07, 2024 pm 03:02 PM

图片消失如何解决先是图片文件上传$file=$_FILES['userfile'];  if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

See all articles