LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2014, 08:01 AM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
How to edit php files properly


Someone suggested a change to one of our php web pages, so I vi'd the file, commented out the two lines he wanted changed, typed in the two almost identical lines, then saved. Now when I go to load the php page, it doesn't load!

Did I do something wrong or very bad? Even if i comment out the lines i added and uncomment the two old ones, it still won't load.
 
Old 07-29-2014, 08:41 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
/var/log/apache2/error_log is your friend (location of the file may be different on your system)
 
1 members found this post helpful.
Old 07-29-2014, 08:42 AM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks. It seems like whenever I try to comment out individual lines with two slashes, that's what kills it. I just removed the stuff for now to avoid chaos. I'll have to add them back in then see what the log says. Thanks!
 
Old 07-29-2014, 08:46 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,710

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
Maybe. Happens to me too... It is possible that when the file was edited you might of changed something else besides those particular lines. Check the error log files.
 
1 members found this post helpful.
Old 07-29-2014, 08:49 AM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks. It's very weird. I take out those 2 lines I added in, it doesn't load. I delete the two slashes before the two lines that I commented out, and it loads again. it doesn't like my slashes. I'll have to fiddle with it some more when I get some downtime on that system. Good to know where to look though. Thanks.
 
Old 07-29-2014, 09:36 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Regarding comments:

// instead of this

## use this
 
1 members found this post helpful.
Old 07-29-2014, 09:39 AM   #7
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
OK, I'll give that a try too. This php file is littered with // though, so I'm not sure why mine wouldn't work. it did accept the /* */ to comment out the two lines though. Very odd.
 
Old 07-29-2014, 09:49 AM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
php for websites often switch in and out of php on the fly. You can switch out of php and into regular html with a
Code:
?>
and then switch back to php with
Code:
<?php
"//" is a valid comment in php, but not in html. Maybe the problem is you're in an html section of the code and are trying to use "//"? Although I'm not sure why /* */ would work in that case.

Last edited by suicidaleggroll; 07-29-2014 at 09:51 AM.
 
1 members found this post helpful.
Old 07-29-2014, 09:56 AM   #9
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
That's an interesting little tidbit. And I wonder if that might have been the case. and I see an error in my original post, I believe it actually just loaded a blank/all white page, it didn't "not load" as in "this page can't be found" type warning, so maybe it was telling me the html was busted so it skipped all the other stuff.
 
Old 07-29-2014, 02:30 PM   #10
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Raspbian, Ubuntu, Chrome/Crouton
Posts: 374

Rep: Reputation: 50
I use phpedit. It is fairly lightweight and includes a php syntax checker. No more unbalanced quotes or parenthesis.
 
Old 07-29-2014, 02:38 PM   #11
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks for the suggestion.
 
Old 07-29-2014, 10:42 PM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Simple idea: after editing, try the file with php-cli:
Code:
$ php somefile
if you have syntax errors, it will tell you
 
1 members found this post helpful.
Old 07-30-2014, 07:39 AM   #13
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
I like simple :-)
So does that essentially just validate the syntax, or does it do other stuff to the file as well?
 
Old 07-30-2014, 08:48 AM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Something else that you ought to be doing is ... source-code control!

In other words, you make the change to the file, and then you "commit" a branch containing the change into the source-code control system (say, "git"), tagged to the particular trouble-ticket or work-order that prompted the change.

You then "check out" that branch onto a test server, and thoroughly validate the change. If the change is good, it's merged onto the appropriate test-branch (and validated again). In due time, the test-branch is merged into a branch off of production corresponding to a "release candidate."

The only way that the production files can get changed is by "checking out" a particular approved release-candidate branch onto that server. Files are never changed directly, and the "correct state" of the server always corresponds exactly to a particular branch and a particular tag within that branch. Thus, the server can always be reverted to any other known good state in a matter of milliseconds.

Last edited by sundialsvcs; 07-30-2014 at 08:49 AM.
 
Old 07-30-2014, 09:03 AM   #15
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open edit Php file problem (PhP apache installed) waerfwe Programming 3 06-30-2011 09:29 AM
how-to properly edit lilo to boot 2nd linux partition agrestic Slackware 12 01-27-2009 11:52 AM
xfree86 and imakefile: how do I edit it properly? Cyberman Linux - Software 0 12-29-2007 08:32 AM
how to properly edit xpm files epoo Linux - Software 4 01-08-2007 02:32 PM
cant edit text files properly in vi and fluxbox soldan Linux - Newbie 5 11-18-2006 12:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration