I have a problem that I am unable to resolve.
我有一个问题,我无法解决。
I have two files: conexion.php
and query.php
我有两个文件:conexion.php和query.php
The conexion.php
file creates a connection to the database in the variable $link
. The code works fine.
conexion.php文件在变量$ link中创建与数据库的连接。代码工作正常。
The query.php file queries the database using the connection created ($link
).
query.php文件使用创建的连接($ link)查询数据库。
I use:
include('conexion.php');
The files are in the same directory. If I copy the conexion.php code into query.php works fine, but if I use "include" or "require" it doesn't work.
这些文件位于同一目录中。如果我将conexion.php代码复制到query.php工作正常,但如果我使用“include”或“require”它不起作用。
Because I use SVN, the directory that contains my website in Apache is a "symbolic link" to a copy of SVN repository. If I copy the files to a real directory of Apache, the files work fine, but I need work with SVN.
因为我使用SVN,所以在Apache中包含我的网站的目录是指向SVN存储库副本的“符号链接”。如果我将文件复制到Apache的真实目录,文件工作正常,但我需要使用SVN。
Now, I describe the directory Structure:
现在,我描述目录结构:
Website in Apache: /var/www/website/
Apache网站:/ var / www / website /
SVN copy: /home/svn/backend
SVN副本:/ home / svn / backend
Symbolic link: /var/www/website/backend --> /home/svn/backend
符号链接:/ var / www / website / backend - > / home / svn / backend
$> ls /home/svn/backend
conexion.php
query.php
http://localhost/website/backend
1 个解决方案
#1
0
You may find specifying the full path with __DIR__
fixes it because you're referencing query.php
from a different place:
您可能会发现使用__DIR__指定完整路径会修复它,因为您从其他位置引用query.php:
include __DIR__.'/conexion.php';
#1
0
You may find specifying the full path with __DIR__
fixes it because you're referencing query.php
from a different place:
您可能会发现使用__DIR__指定完整路径会修复它,因为您从其他位置引用query.php:
include __DIR__.'/conexion.php';