DougJ51 Posted June 1, 2012 Share Posted June 1, 2012 Hi, My question is why won't this script run when I execute on the webserver where I have a dummy webpage setup. I created a website on Bluehost.com and I know it is setup correctly as I have run other php scripts on it for this book and for other books as well. When I am looking at the code below in DreamWeaver it tells me the lines with the variables have syntax problems and won't run. The code is copied exactly from the book so I'm stumped while I am getting the syntax errors. I've tried uploading the file to my webpage and it won't run there either so something is wrong. Will this file only execute if I am using Apache? Here is the code. The text colored red is where DreamWeaver says there are syntax errors. Thanks in advance for your help! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pre Defined Variables</title> </head> <body> <?php # Script 1.5 - predefined.php // Create a shorthand version of the variable names: $file = $_SERVER['SCRIPT_FILENAME']; $user = $_SERVER['HTTP_USER_AGENT']; $server = $_SERVER['SERVER_SOFTWARE']; // Print the name of this script: echo "<p>You are running the file:<br /><b>$file</b>.</p>\n"; // Print the user's information: echo "<p>You are viewing this page using:<br /><b>$user</b></p>\n"; // Print the server's information: echo "<p>This server is running: <br /><b>$server</b>.</p>\n"; ?> </body> </html> Link to comment Share on other sites More sharing options...
HartleySan Posted June 1, 2012 Share Posted June 1, 2012 More than likely, your hosting service is restricting access to the $_SERVER superglobal because it gives away too much information about their service (or for some weird reason like that). Beyond that, I can't really imagine what the problem is. I would try running this script on another server, if possible, and seeing what happens. If it works, then perhaps contact Bluehost.com, and ask them about the $_SERVER superglobal. Link to comment Share on other sites More sharing options...
DougJ51 Posted June 1, 2012 Author Share Posted June 1, 2012 Hi HartelySan, Thank you for your reply. I think the problem has to do with why DreamWeaver is saying that the variable declarations have a syntax error. Does anyone know if in PHP you have to declare a Global before being able to use them? Something is wrong and I have a feeling it has to be something simple. Thanks, Doug Link to comment Share on other sites More sharing options...
HartleySan Posted June 1, 2012 Share Posted June 1, 2012 I ran your script in XAMPP, and it executed perfectly fine, so there are no syntax errors. It must be something with your server setup and how it's not allowing you to use the $_SERVER superglobal. Like I suggested, try running the script on another server, and see what happens. Link to comment Share on other sites More sharing options...
DougJ51 Posted June 1, 2012 Author Share Posted June 1, 2012 I tried running it in WAMPP and received this error: Parse error: parse error in C:\wamp\www\predefined.php on line 15 Link to comment Share on other sites More sharing options...
margaux Posted June 1, 2012 Share Posted June 1, 2012 I copied and pasted the code from your first post and ran it in MAMP - worked perfectly Link to comment Share on other sites More sharing options...
HartleySan Posted June 1, 2012 Share Posted June 1, 2012 Doug, not sure what to tell you, but there must be something up with your server setup(s). Hopefully Larry or someone more educated on the matter can lend a helping hand. I still think sending a question off to your hosting service can't hurt though. Link to comment Share on other sites More sharing options...
DougJ51 Posted June 1, 2012 Author Share Posted June 1, 2012 Sorry guys - this is new to me and I just don't know why it won't work on my computer. Maybe I should try it on my Mac instead of my pc Thanks for everyone's patience and understanding. I appreciate your efforts to help me. Link to comment Share on other sites More sharing options...
DougJ51 Posted June 1, 2012 Author Share Posted June 1, 2012 Hi Hartely - I sent them the the information as you mentioned above and it worked OK for them too. I don't know why dreamweaver is keep stating I have syntax errors. Link to comment Share on other sites More sharing options...
Paul Swanson Posted June 1, 2012 Share Posted June 1, 2012 Maybe Dreamweaver isn't configured for PHP? Just guessing, as I don't use Dreamweaver. You might try a different IDE, such as Netbeans with the PHP plugin. Don't be put off by all the Java references. It's primary supported language is Java, but it supports many other languages. It's free. Many people use Dreamweaver for PHP, though, so if you're comfortable with it you can continue to use it. Link to comment Share on other sites More sharing options...
Larry Posted June 4, 2012 Share Posted June 4, 2012 I haven't used DW much myself, so couldn't really guess what's going on there. Link to comment Share on other sites More sharing options...
Jonathon Posted June 4, 2012 Share Posted June 4, 2012 My DW says No Syntax Errors Link to comment Share on other sites More sharing options...
Recommended Posts