Jump to content

[SOLVED] Can't publish PHP files!


sdallas411

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/150032-solved-cant-publish-php-files/
Share on other sites

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.

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.

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.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.