January 13th, 2013, 03:04 PM
Php Code Not Working At All!!!!!!!!!
hi guys i am newbie. My php code is not working at all. When i post say this:
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.
January 13th, 2013, 03:37 PM
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?
January 13th, 2013, 07:33 PM
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.
January 13th, 2013, 08:01 PM
You need to save it as filename.php so the webserver will parse it.
Originally Posted by kumsan
January 13th, 2013, 08:29 PM
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
Originally Posted by BarryG
January 13th, 2013, 08:40 PM
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.
January 13th, 2013, 08:46 PM
Originally Posted by E-Oreo
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>?
January 13th, 2013, 09:16 PM
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.
January 13th, 2013, 11:24 PM
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.
January 14th, 2013, 01:23 AM
Totally agree, I've used notepad++ for a couple of years now and haven't looked back!
January 14th, 2013, 07:39 AM
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.
January 14th, 2013, 07:51 AM
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
and upload it to your server, then try and access it
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
January 15th, 2013, 07:54 AM
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!!!
January 15th, 2013, 01:02 PM
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.