connect with include

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Flavio
Forum Newbie
Posts: 5
Joined: Sat Feb 07, 2004 6:18 pm

connect with include

Post by Flavio »

Hi,

Sorry to molest for such a small "beginner" issue. In order to connect I use the following script in access.php (<?php include('../access.php'); ?>

<?php
if (!$db = mysql_connect('localhost', 'user', 'pass')) {
die('mySQL error: '.mysql_errno().':'.mysql_error());
}
if (!mysql_select_db('pass')) {
die('mySQL error: '.mysql_errno().':'.mysql_error());
}
?>

error is the following:
Warning: Failed opening '../acceso.php' for inclusion (include_path='./:/usr/local/lib/php') in /home2/user/site-www/page.php on line 1

What did I wrong (the connection works) or better what do I have to do to correct this.

Thanks a lot for any help
Flavio
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Where is "access.php" located in relation to your script? By using "../" you are specifying that it is a folder above where the script is, is this correct?
Flavio
Forum Newbie
Posts: 5
Joined: Sat Feb 07, 2004 6:18 pm

Post by Flavio »

Hello,
Thanks for your help.

The file is located in the same folder as the script(s). I also tried with full url but the result is teh same.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Do this then

Code: Select all

<?php
include("access.php"); ?> 
?>
.......
Flavio
Forum Newbie
Posts: 5
Joined: Sat Feb 07, 2004 6:18 pm

Post by Flavio »

Sorry, error was following: Parse error: parse error in /home/user/www/file.php on line 2
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

double php closing tags
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Re: connect with include

Post by Dr Evil »

Flavio wrote: include('../access.php');
Flavio wrote: Warning: Failed opening '../acceso.php' for inclusion (include_path='./:/usr/local/lib/php') in /home2/user/site-www/page.php on line 1
Are you sure you got your filenames straight ?

Dr Evil
Flavio
Forum Newbie
Posts: 5
Joined: Sat Feb 07, 2004 6:18 pm

Post by Flavio »

Yes filenames are correct acess = acceso
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

Is this now corrected ? Does your script work Flavio?
Flavio
Forum Newbie
Posts: 5
Joined: Sat Feb 07, 2004 6:18 pm

Post by Flavio »

No the result is still the same (code are correct - I just used translation for better undestanding) Thanks any how
Post Reply