#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0

    Php Code Not Working At All!!!!!!!!!


    hi guys i am newbie. My php code is not working at all. When i post say this:
    <?php
    echo 'something';
    ?>
    its not even posting the echo. see i have been trying to write a code for user registration n login and it did not work at all. the html form is showing but all i get from the php part is literally this : ?> In fact from the echo code i posted above, the same thing happens, only ?> shows. Can someone help me, i tried reading so many tutorials & forums for solution but cant seem to find one. Pls help.

    Cheers

    Kums
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    294
    Rep Power
    8
    Can you post your code where you are trying to echo 'something'.

    What is the extension of the filename you are running this echo statement in?

    Regards,

    NM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    <?php

    echo "Hello";

    ?>


    I am simply giving this to you as an example. even this is not echoing. When i post a php code using kompozer all it does is, it display the ?> at the end of the script. I am actually trying to wrikte a user login n registration script. so when i was done writing it and posted it into my server, it was not working all it ever did was it display ?> just like the php code above. So i realise the issue is not with the code i wrote, i think the code is fine but then there is something else that is wrong that i cant seem to figure out. Can you pls help, i cant seem to think of a solution

    And as for the extension, since it is posted in kompozer, i save the page as html and then upload it to the server.

    Thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    Sydney Australia
    Posts
    178
    Rep Power
    83
    Originally Posted by kumsan

    And as for the extension, since it is posted in kompozer, i save the page as html and then upload it to the server.

    Thanks
    You need to save it as filename.php so the webserver will parse it.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by BarryG
    You need to save it as filename.php so the webserver will parse it.
    so what you are saying is, i need to write it and then save it as a separate php file. then upload to the server. next, paste the code in kompozer n then upload?? i am a bit confused
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,300
    Rep Power
    7170
    The name of the file on the server needs to end in .php, but it doesn't matter how the file gets to the server as long as it is named right.

    I don't know much about kompzer, but it doesn't look like it is really designed to work with PHP. This might actually be making the process more difficult for you. You might consider writing your code in something like notepad++ instead.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by E-Oreo
    The name of the file on the server needs to end in .php, but it doesn't matter how the file gets to the server as long as it is named right.

    I don't know much about kompzer, but it doesn't look like it is really designed to work with PHP. This might actually be making the process more difficult for you. You might consider writing your code in something like notepad++ instead.

    thats right, thats wht i did. i wrote my php in notepad++ and then pasted the code in kompozer and the upload it. so are you saying that i should just save st as a php file and upload that in my server? if thats the case, how does the php code get attached to a certain link>?
  14. #8
  15. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,300
    Rep Power
    7170
    The PHP file is accessed in the same manner as an HTML file; ie: if you upload the file to /file.php, then the address to it will be http://domain.com/file.php.

    There are two potential problems with copying and pasting the code into kompozer and using that to upload it:
    1) kompozer might escape or otherwise modify the PHP code that you paste into it because it does not recognize it as code and thinks you are trying to paste in normal text.
    2) kompozer sounds like it is uploading the code to a file that is named ending in .html, which will not work. You might be able to change the name of the file in kompozer so that it ends in .php, but since I have never used kompozer I cannot tell you how to do this.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  16. #9
  17. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    400
    Rep Power
    311
    i just looked into kompozer a little bit, and it looks like it is just a wysiwyg editor.

    If you are serious about web design / web development, steer away from stuff like that. Use a text editor with syntax highlighting (notepad++ for win, Textmate for mac, gEdit / pluma for linux are my recommendations) and code by hand.

    Once you've finished editing your files, use a dedicated ftp program (filezilla is my choice for windows, command line scp for mac / linux) to upload the files to your server.

    That way you are in full control of your code etc. Wysiwyg editors generally create really bloated code, and it may not be allowing you full control of how it uploads etc.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?
  18. #10
  19. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    294
    Rep Power
    8
    Totally agree, I've used notepad++ for a couple of years now and haven't looked back!

    Regards,

    NM.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,799
    Rep Power
    529
    Are you sure you are looking at the correct file with your browser? Before you say of course, check again. Try putting another file type in the same directory, and see if you can access it. Make sure that your edits are actually taking, and you are not experiencing a permissions problem.

    Also, always good to check the HTML source code. Sometimes you view a page, and say "nothings there" only to find content is hidden in a script tag.
  22. #12
  23. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,660
    Rep Power
    4123
    php is the language and the name of the software that interprets the language.

    Your webserver needs to know that you want the code executed as php code.

    I bet if you looked at the source of your originally not working page you'd see the raw PHP code in there. This shows that the php software is not being told to process the php code.

    Generally, a web server is configured to send *.php files off to the php software (engine) to get the content.

    If komposer is part of a CMS then its very unlikely that anything you do will allow the php code to be executed.

    If you have ftp access, try putting this into a file called info.php

    Code:
    <?php
    phpinfo();
    ?>
    and upload it to your server, then try and access it

    http://your-host/path/to/info.php

    and see what it says.

    Locally, get yourself something like xampp to install apache, MySQL, and PHP - you'll get more of an idea how servers work wrt procesing requests and executing code
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    12
    Rep Power
    0
    You gusy were right!!! It is because of wrong extension. First error i made was, when i added the target url for the link i wanted to post the php, i added it as "login.html". It shoud have been "login.php". Secondly, like you guys said, it shud hv been saved as a php extension. I have corrected the error and i tested with a simple php code and it works!!!! thanks very much!!!
  26. #14
  27. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,176
    Rep Power
    1469
    I'm glad you got up and running. As these guys have mentioned, you really should look into using a proper "code editor". There are tons of them to choose from. Some really great ones are absolutely free and they range from simple text editors to full development environments. They will help you write code more efficiently and ensure that any special characters are being handled properly. You will also have better control over line endings.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!

IMN logo majestic logo threadwatch logo seochat tools logo