Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse errors in include command

Status
Not open for further replies.

pcsmurf

IS-IT--Management
Apr 26, 2002
47
GB
The following code:

<?php
// Include the MySQL class
ini_set("include_path",'\include "MySQL.php";
?>

works on a unix based server but on our windows based server gives the error message:

Parse error: parse error, unexpected $end in E:\IntraNetData\ on line 9

If I change the quotes to " instead of ' the error changes to:

Parse error: parse error, unexpected T_STRING in E:\IntraNetData\ on line 5

I'm thinking along the lines of characters being escaped incorrectly but I still haven't found a way of getting the code to run correctly. Has anyone any suggestions ?
 
Sorry, the lines shown above are the complete file but I removed the blank lines.

line 9 is the last line: ?>
line 5 is the line: include "MySQL.php";
 
Also, have you tried using forward slashes instead of backslashes in your path?

I understand you're running PHP on a Win32 machine, but PHP will still know what you're talking about.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yes. I originally tried using the full path but with errors saying that the file could not be found. I assumed this to be some problem with the path being used to find the files so I tried explicitly setting the search path.

I've also tried using forward slashes without success.
 
Using the code:

<?php
include ("\?>

I get the following errors:

Warning: main(\ failed to open stream: No such file or directory in E:\IntraNetData\ on line 2

Warning: main(): Failed opening '\ for inclusion (include_path='.;c:\php4\pear') in E:\IntraNetData\ on line 2
 
I think I see the problem. You're assuming that include() is constrained by the document root of your current web site. It is not.

"\ is not referring to "E:\IntraNetData\ but rather to "E:\
Another thing...If you're going to use backslashes as parts of filenames in a PHP string literal, either use single quotes or escape your backslashes. If, for example, you were to use:

include ("\new_file.php")

PHP would interpret the string not as "backslash new_filename.php" but as "newline new_filename.php"



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top