tags:

views:

82

answers:

2

I'm stumped!

In PHP in Netbeans (6.8), a project has two files, file1.php and file2.php

file1.php starts require_once('file2.php'); and I get

Warning: require_once(query_form.php): failed to open stream: No such file or directory in C:\xampp\htdocs\my_project\file1.php on line 3

Call Stack:
0.0741     322920   1. {main}() C:\xampp\htdocs\my_project\file1.php:0


Fatal error: require_once(): Failed opening required 'file2.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\my_project\file1.php on line 3

Call Stack:
0.0741     322920   1. {main}() C:\xampp\htdocs\my_project\file1.php:0

I tried require_once('./file2.php'); and require_once('.\file2.php'); since it is windows. I even added C:\xampp\htdocs\my_project\ to the projects include path and it shows up as such on the prject view and see file1.php and file2.php It doesn't show up on this error report, but possibly because Netbeans (or PHP ]) knows that C:\xampp\htdocs\my_project\ === .

Any suggestions? Btw, I am new to Netbeans, so it i sprobably something very obvious.


Here are the first few lines of code, as requested

<?php
require_once('query_form.php');

$user = 'root';
$password = '';

 if (ConnectToDefaultDatabase($user, $password) === False)
  {
    ....

File1 above is actually index.php (shown here) and file2 is query_form - I just tried to simplify


Just out of curiosity - does the one who voted this down have the cojones to step forward and say why? I had a problem, I asked a question, it got solved, but along the way everyone who helped got +1 from me.

I don't really mind being voted down, just wondered why you didn't attempt to explain

+1  A: 

Did you try to run it outside Netbeans? Are the files in the same directory ? What is the line 3 in file1.php (I ask because you have a warnig and a fatal error in the same line).


This should be a comment but I cannot use it yet :(

veritas
+1  A: 

Probably some toying around with the working directory somewhere.

require_once(dirname(__FILE__).'/file2.php'));

And if that doesn't work, copy the filename from a filemanager window & insert that, you wouldn't be the first to have either stray characters or a nasty typo which for some reason always escapes detection :)

Wrikken
+1 for some good suggestions. The dirname() made no difference, and when I copied the file2 into file1 it ran ok, so no stray characters. Btw, Netbeans has a menu option Run/Validate file - but it seems to be permanently greyed out - any ideas?
Mawg