sdallas411 Posted March 18, 2009 Share Posted March 18, 2009 I am of course new to PHP. I am simply trying to put some PHP files I both wrote and got from examples from a book's CD onto the www. The sample files from the CD work just fine but even if I just modify the text within them and put those on the www, they don't work. I get a syntax error and I think it always points to the very first line of PHP in the code. I assume this has something to do with my computer but I did go thru all the configurations as instructed on various sites to I guess activate PHP. I have a new macbook pro running Leopard. I usually use textwrangler, fetch and safari but I have tried other programs with the same result. Not sure if the PHP installation process was done right since I don't notice any difference with anything but when I go to http://localhost/phpinfo.php, the correct site does come up. Please help!! I'm taking a crash course in PHP and learning so much so fast but it doesn't make a difference if I can't get my work out to the world!!! Thank you so much for reading! -Dallas Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 18, 2009 Share Posted March 18, 2009 Hey start here: http://www.phpfreaks.com/forums/index.php/topic,243697.0.html Then let me know what your results are. Also more detail about the error, like post the error message. Quote Link to comment Share on other sites More sharing options...
Redlightpacket Posted March 18, 2009 Share Posted March 18, 2009 I'm really not sure what you are doing, but if you are a beginner programming in PHP and have a pc. I suggest you get WAMP to run your php scripts on. I hope this helps. Quote Link to comment Share on other sites More sharing options...
sdallas411 Posted March 18, 2009 Author Share Posted March 18, 2009 Thank you all for very sppedy replies. Appreciated!! Since I'm a sitting duck right now. This is what I took directly from a learning CD which works fine http://www.djdallasjones.com/11/numguess.php This is what happens after I just slightly changed some echoed text, basically what is says once you select the right number. http://www.djdallasjones.com/11/numguessaltered.php The error reads: Parse error: syntax error, unexpected '?' in /home/content/s/d/a/sdallas411/html/11/numguessaltered.php on line 19 although it is only line 10 that I changed. Line 19 is: <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"> Thank you again! I'll check out that other area of the forum too. Quote Link to comment Share on other sites More sharing options...
Rodis Posted March 18, 2009 Share Posted March 18, 2009 can you give more code if it says line 19 the error could be made before that like when you accidently forget a ; or ' > Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 18, 2009 Share Posted March 18, 2009 I'm really not sure what you are doing, but if you are a beginner programming in PHP and have a pc. I suggest you get WAMP to run your php scripts on. I hope this helps. He said in the begining he owns a new Macbook running Leopard OS. Can you post the code prior to edit and the code after edit for me. I am at work and your site is blocked because it is not catagorized. Quote Link to comment Share on other sites More sharing options...
sdallas411 Posted March 18, 2009 Author Share Posted March 18, 2009 here's the code: <?php $num_to_guess = 42; if (!isset($_POST["guess"])) { $message = "Welcome to the guessing machine!"; } else if ($_POST["guess"] > $num_to_guess) { $message = $_POST["guess"]." is too big! Try a smaller number."; } else if ($_POST["guess"] < $num_to_guess) { $message = $_POST["guess"]." is too small! Try a larger number."; } else { // must be equivalent $message = "This is the only part I changed; } ?> <html> <head> <title>A PHP number guessing script</title> </head> <body> <h1><?php echo $message; ?></h1> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"> <p><strong>Type your guess here:</strong> <input type="text" name="guess"></p> <p><input type="submit" value="submit your guess"/></p> </form> </body> </html> In line 10 is the only thing I changed in this. Before the change it worked fine, now it doesn't. I assume it has something to do with my macs ability to save and make PHP code? I don't know much about how that works behind the scenes but as I said above I did configure my mac files as instructed for PHP and I do get the correct site when going to localhost/phpinfo.php THanks again everyone! This is a great site. Quote Link to comment Share on other sites More sharing options...
Rodis Posted March 18, 2009 Share Posted March 18, 2009 $message = "This is the only part I changed; you forgot " $message = "This is the only part I changed"; Quote Link to comment Share on other sites More sharing options...
sdallas411 Posted March 18, 2009 Author Share Posted March 18, 2009 I'm glad I noticed this before anyone else cause now I just feel like a dumbass. But I revel in that feeling. Always! After my altered message I didn't have a closing " Now it works. Makes me wonder though about my other file that didn't work either but I guess it's a similar small error. Don't hate me!!! I'm new to this and thought it might have been something bigger or with the installation process. Thank you to all that read! I greatly appreciated this site and it's users. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 18, 2009 Share Posted March 18, 2009 No one hates you, it has happened to all of us at some time. We all were new at some point. Please mark the post solved. Quote Link to comment Share on other sites More sharing options...
Rodis Posted March 18, 2009 Share Posted March 18, 2009 I noticed before you lol don't worry even experinced look over little things like that especially when you have lot of code it is easy to overlook. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.