The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP5 - Php Code Not Working At All!!!!!!!!!
Discuss Php Code Not Working At All!!!!!!!!! in the PHP Development forum on Dev Shed. Php Code Not Working At All!!!!!!!!! PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 13th, 2013, 03:04 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 11
Time spent in forums: 2 h 8 m 54 sec
Reputation Power: 0
|
|
|
PHP5 - 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
|

January 13th, 2013, 03:37 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
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.
__________________
"WERE NOT WORTHY!"
"WERE NOT WORTHY!"
|

January 13th, 2013, 07:33 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 11
Time spent in forums: 2 h 8 m 54 sec
Reputation 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
|

January 13th, 2013, 08:01 PM
|
|
Contributing User
|
|
Join Date: Aug 2011
Location: Sydney Australia
|
|
Quote: | 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.
|

January 13th, 2013, 08:29 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 11
Time spent in forums: 2 h 8 m 54 sec
Reputation Power: 0
|
|
Quote: | 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
|

January 13th, 2013, 08:40 PM
|
 |
Lost in code
|
|
|
|
|
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
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 11
Time spent in forums: 2 h 8 m 54 sec
Reputation Power: 0
|
|
Quote: | 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>?
|

January 13th, 2013, 09:16 PM
|
 |
Lost in code
|
|
|
|
|
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
|
 |
Known to taste like chicken
|
|
Join Date: Aug 2003
Location: In front of my computer
|
|
|
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?
|

January 14th, 2013, 01:23 AM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
Totally agree, I've used notepad++ for a couple of years now and haven't looked back!
Regards,
NM.
|

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
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
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
|

January 15th, 2013, 07:54 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 11
Time spent in forums: 2 h 8 m 54 sec
Reputation 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!!!
|

January 15th, 2013, 01:02 PM
|
 |
|
|
Join Date: Jan 2004
Location: New Springfield, OH
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|