Portal Home > Knowledgebase > Articles Database > please help with php please!!!!!!


please help with php please!!!!!!




Posted by andyxfun, 08-25-2009, 06:56 AM
i'm such in a hurry right now and please don't mind if my message sounds so desperate but i really need this project done for school so i have to finish it in 4 days but i'm new to php so.... please can you tell me why doesn't my code work??? so i have these files in the Contact folder: contact.htm pic.jpg contents.htm template.htm save.php mail.php so the contact.htm file uses save.php which includes at the end the mail.php now the problem: i used opera and it says save.php cannot be accessed at that time and using firefox,nothing appears on the screen!!!...please help save.php: and mail.php: i must say that the mail.php uses the phpmailer and all settings are ok,i think that the problem is save.php but i gave mail.php anyway,if it helps so where is the problem?or problems... thanks very much in advance!!!

Posted by bear, 08-25-2009, 07:32 AM
So, you don't see a problem with the section that begins with this bit? What PHP that you recall can begin with an unrelated number and a "."" and still work? Just so you're aware, that tells PHP tp take the number and concatenate (append) it to the string that follows... Start by cleaning that whole section up and see if anything then works.

Posted by andyxfun, 08-25-2009, 08:21 AM
snipped>> thanx again,going to try that out...im using a php editor and that didn't seem to bother it...thanks very much!

Posted by andyxfun, 08-25-2009, 08:36 AM
ok,tried it,it's better now,also put in some die(); after each check fail and deleted the echo $htm from the end and trying to get it working right now... ill tell you the outcome later thanks very very much anyway!!!

Posted by andyxfun, 08-25-2009, 08:45 AM
ok,it's not working...first i repaired some problems,i deleted the image check for instance and some other problems but still not working,the same outcome as the first time: with operaome error,could not locate the save.php file and could not access it and with firefox nothing appears...( what could be the problem this time?? the code now: and it's all related to this save.php file i think....i won't even get to the mail.php but it gets through the email address check (it gave me the email error once so it's ok there) so the problem should be caused by some of these lines: i can't explain it...i told you i'm just a lil php noob... any idea?

Posted by D3acon, 08-25-2009, 12:15 PM
What is the URL?

Posted by egiblock, 08-25-2009, 01:40 PM
since you are using firefox, get the extension "firebug" and "firephp" to help you with the php code. could you post all of the source files here the way they are now, and i'll take a poke at it.

Posted by petteyg359, 08-25-2009, 03:24 PM
Add error_reporting(E_ALL); to the top of the file. Knowing what the error is can be extremely helpful with debugging. Something that might drastically improve the reputation of your skills / knowledge would be to never name a Javascript-related function "java_something". Javascript isn't Java, nor is it even related to Java in any way other than both being programming languages.

Posted by andyxfun, 08-25-2009, 03:53 PM
here you are: template.htm: sorry about the language,ignore it,it's not english,only take a look at the script... here is contact.htm and as you can see,the address is http://www.verde.22web.net from the homepage,you go to the contact area... here is save.php: and here is mail.php: so can you figure it out?? it just freezes and nothing happens,no mail arrives... and for editing php,i use NuSphere PhpED please help me....and thanx!

Posted by andyxfun, 08-25-2009, 03:56 PM
and yes,i'll try to add the error report to it in the morning! thanks!

Posted by bear, 08-25-2009, 04:21 PM
So this is homework?

Posted by gewthen, 08-25-2009, 04:35 PM
If this is for school then asking for help here constitutes cheating. Accept whatever grade you get from doing the work alone without help.

Posted by mattle, 08-25-2009, 04:51 PM
I disagree...would you allow yourself to get fired from your job because you couldn't solve a programming issue you were assigned without help? I've been doing this for over a decade, and I've ALWAYS got my head in some manual, API doc, forum, newsgroup, etc. There's no way that anyone reads a PHP book, commits every function and syntax to memory and then programs in a vacuum for the rest of his/her life. Half the battle is learning how to get help when you need it. The other half is understanding the help you get so you don't come back next time asking the same questions. @andyxfun: You seem like you're in over your head here...and since your first post was blowing up on some line numbers prefacing your code, I'm inclined to believe you've been cutting and pasting scripts you don't understand. You got a long way to go if you're going to 1) get this done on time and 2) understand what you're doing here. Start with the error reporting suggestion. I would also print out some explanatory debugging information right before every "return false;" statement. You should also read up on the difference between http://us2.php.net/die and http://us2.php.net/exit EDIT: A perfect example. After posting, I re-checked the docs and found out that die() and exit() are equivalent in PHP...not so in Perl. Had I not rechecked, surely someone here would have reminded me Last edited by mattle; 08-25-2009 at 04:55 PM.

Posted by gewthen, 08-25-2009, 09:20 PM
The difference is that this is for a class. Academics and classes are not part of the professional world. Most classes require no help (at least in all the classes I took) from any unapproved outside sources. I doubt you have been taking college level classes or higher for ten years. If however you are referring to getting help for problem you find while in a job, then I agree seeking help anywhere is fine. I agree in a professional non-academic setting, but in an academic setting if you learn that you need help and you go out and ask for the answer, then I don't know what else to call that other than cheating.

Posted by nickia, 08-25-2009, 10:24 PM
I don't want to sound harsh here but your logic seems absurd. Let's say if you are studying math and got stuck in a question and ask someone for help, and you would call that cheating? Students have been doing this for century. I hope you are not suggesting people should lock themselves into a confined room and figure out everything by themselves.

Posted by egiblock, 08-25-2009, 10:38 PM
if you were working on a test, i'd say you are cheating. if you are doing homework, then there is a thin line there.. just my 2cents.. i'm finishing my masters degree, and if it wasn't' for forums like this, i wouldn't be where i am today.

Posted by egiblock, 08-25-2009, 10:42 PM
could be my own install problem because i don't have a mail server on my test machine, but:

Posted by petteyg359, 08-26-2009, 12:42 AM
Seriously, at least download the effing library the code includes. A simple 2-second Google for PHPMailer isn't hard. Don't act like those errors are the fault of the code...

Posted by andyxfun, 08-26-2009, 01:47 AM
ok so now my reply: i haven't inserted the error_reporting(E_ALL); at the top of the page yet (i'll do that next) but i feel like i need to post a reply down here: this is not homework,nor job...i tend to take it like something in-between: as i said before it's a project: there is some kind of contest at school at the end of the summer vacation and it's all about ecologic websites.there are no age categories so i have a disadvantage from the very begining... and to tell you why i sound like a noob in so many ways: because i am...no,really i am! i just started learning php from tutorials and examples as before this i just worked with simple html websites done for fun,for me and my friends...so php is relatively new for me and javascript is...more than new,something yet undiscovered so sorry about the "java something" name and about the numbers and points,yes,you are right,i did copy-and-paste that code because it was far over my level to make a mail address checker and i know that the "." concatenates two strings but i just didn't saw those...(d.a.m.n) i use this NuSphere which is really great php editor and has those numbered rows that help alot but heck...i didn't saw the others,sorry and now for the contest,you'll say i'm cheating but i don't think so,anyway it's not something important,just formal stuff,no prizes but still...and i must say:these kind of forums,net tutorials and practicing my skills is my way of learning...and yes,this forum has helped me much and i am grateful for this,but still help does not necessary mean cheating as i am learning with the help of others! so thanks very much! and i'm going to post the rest of the problems in a minute! cheers!

Posted by andyxfun, 08-26-2009, 02:01 AM
look,i just inserted the error_reporting(E_ALL); at the top of the save.php page,right? like right after the

Posted by gewthen, 08-26-2009, 02:37 AM
Wrote this late at night, so there are probably several typos and mistakes.... I don't know whether the universities or high schools you went to had honor codes, but the places where I went to (highschool, undergraduate, and graduate school) all pretty much said that if the professor did not explicitly allow outside help, and you seek outside help from students or any other sources other than the professor, the book, and class notes (and its not a collaborative assignment) then you are cheating and if caught then various things would happen (e.g. a three time rule, announcing to everyone that you cheated, or expulsion). Granted its the decision of the professor, but in this case I perhaps wrongly assumed such radically high standards that I was required to face. Academic work at the undergraduate level and most graduate level course work are all YOUR OWN work and nothing but your work (not counting research, and approved sources). If you have to seek out other sources not provided to even get a passing grade then the class is over your head. Another possibility is that your professors are lazy and which case everyone does it to some degree. In this instance you should really go somewhere else where the professors really do care and not just given an appearance of caring. When it comes to cheating, if you find additional information that gives you information to form an answer, then its possibly not cheating. However if your professor is too lazy to come up with his own questions and gets them from a book you find in the library and the answers also exist in the book, then you've just cheated. As for your math question example, yes asking other students for help on a math question is cheating because students almost always give answers to each other without explanations. Even with explanations there is no guarantee that the student understands why the answer is the answer; he is in a rush to get it completed more than to gain understanding. Moreover even asking whether a question is right or wrong before it is graded is cheating if an answer is given. I had one Math professor who wouldn't budge at helping me unless I got to a particular depth into a problem. Such an attitude was annoyingly helpful. In some cases the professor allows collaboration among students in the class for the homework in which case discussion is not cheating, but there is no way of knowing that when someone asks for an answer to a homework problem in some form. Therefore It would be best not to answer than to be a potential facilitator of cheating. What I've said comes from that assumption that "I don't know whether giving an answer would cause the student to cheat." and so I assume I would. I assume he is seeking to cheat just to get the answer and move on with the assignment. I don't mean for the student to lock himself up in a room, but perhaps that room should be confined to his professor and the people that are allowed to go in it. I really doubt the professor would allow the whole world (by posting the question on the internet) to be allowed in such a room. I would also mention that one of the schools I went to did a statistical analysis of code between all students (current and past). If there were statically identical code you would be charged with cheating. So students avoided looking at each others code to prevent a possibility of writing too similar code. You couldn't share solutions in the detail sense, and so getting help from each other wasn't very helpful. Getting code from forums was an automatic cheating if some other student got the same code or it was used in the past and so, as far as I know, no one bothered posting questions about code problems. Some classes have homeworks/labs be 50% or more of the grade and so by giving answers your giving an unfair advantage to the student. If student A asks a question to a forum of experts and gets answer E and submits E as his work and students B, C don't get the expert answer E, but tried on their own, then B and C are at an unfair disadvantage. B and C realize that to get grades like A they too must ask questions they have difficulty with to a forum of experts. The two ask the questions to the expert forum and are given answers and so their grade becomes how well the community can help the students on questions that are difficult more than the personal ability of the student. Or it becomes how well the student can find the best forum or goggle the best, or formulate the assigned question best. You can't stop the student from initiating this behavior, but it is your complete decision to whether you want to harm his education and the educational system. It is better to fail at something while following the rules and know one's limits than to go forward as a cheater who has deceived himself or others of believing he has more knowledge and skills than what he actually possesses. You really do learn more by banging your head against a problem for hours, days, or weeks until a solution comes. It isn't always fun, but it is ultimately more worthwhile and more learning comes from it. However as a paid professional it is usually considered a waste of time not to seek out an answer when someone else has answered it, but that's a world I'm not talking about. BTW, this all comes from 10+ years involved in higher education, having never asked a single question in any form for anything. Last edited by gewthen; 08-26-2009 at 02:47 AM.

Posted by gewthen, 08-26-2009, 03:01 AM
The fact that you are making a distinction between PHP errors in Firefox and Opera suggests you don't fully understand what PHP is and what is going on. Go to your professor with your problem since you seem to be missing some of the fundamentals. Error codes are usually, but not always, unique to the certain code you are running, so I cannot give you possible error messages. All I can say is for you to read the error message codes, read the appropriate manual page and then go from there. Coding is fun, but having problems is expected when first learning any programming language. Identifying what about the errors message you don't understand might reveal the answers to your problems or at least give you a first step. Scan your code character by character and if you see a character that you don't understand, then it means you don't fully understand the syntax. If you understand the syntax then describe what each line is suppose to do. If you can't do that then you're having problems with understanding programming concepts or the PHP library. Have Fun.

Posted by andyxfun, 08-26-2009, 04:24 AM
ok,ok,i get it...i have to learn more...so if there is no solution provided to me than i might call this thread closed! thank you very much for the help provided,if there are any other problems,i shall open up another thread regarding that specific issue. thanks again and keep up the good work!

Posted by rasin, 08-26-2009, 05:23 AM
in save.php why this line echo ''."\n"; remove that and try actually those will result html comment and nothing displayed in the page hope it helps you Rasin

Posted by mattle, 08-26-2009, 06:18 AM
No, there's no OOP in the OP (j/k) I do see your point, and I think there's a fine line between cheating (ie, attempting to solve the problem without exerting your own effort) and using a resource (ie, attempting to learn more on your own). Yeah, most courses I've taken provided you with plenty of resources to complete an assignment. I can certainly remember others (mostly calculus, for some reason) where the course materials were unclear, professor was largely unavailable, and there was an insurmountable language barrier between myself and the T.A. I also get the impression that a lot of the questions that we see in these forums are now coming from High School classes as well. It's great that there are programming courses at that level of education now, but I can only assume that the overall level of instruction and resources isn't as good as you'd find in a post-secondary academic setting. Either way, the most instructive classes I've ever had are the ones in which the teacher approached the material with the attitude, "I'm going to teach you HOW to learn about/research X for yourself" rather than "I'm going to teach you X." That's really what school is about--learning how to learn.

Posted by mattle, 08-26-2009, 06:21 AM
Case in point....that would be what I'd call the attitude of a cheater. Regardless of what you hear the politicians say, get used to not having all of life's answers "provided to you," or get ready for disappointment.

Posted by andyxfun, 08-26-2009, 08:15 AM
look man,i have no attitude of a cheater,ok?? this whole stuff about the website contest is optional,not some kind of homework and i just make this website to learn ok??i don't gain or lose anything!i don't cheat because there is nothing to cheat at!and if you put it that way,at school,i'm the student type that offers the resolved math questions not the one that asks for them and not only at math but at many disciplines,ok?? after all i just came here to ask for help and the whole discussion went offtopic talking about me cheating or not and things like that... and now to settle this: i surfed the web,searching for answers,scanned my php scripts,found many errors,repaired them(missing files,missplaced files, scripting errors...) and now it's all about this last bit of script which just won't work: the email arrives but with the contents of the template file: what is wrong with the next php file: i have the template.htm,the contents.htm and the save.php in the same foder and after the script ends,the result is iddentical to the template.htm with no changes i got this bit of code right from this forum from another topic,copied and adapted it but it won't work,i tried to search explanations on the net about each function but everything seems ok,can you figure it out? and thanks for the help til now! ps:i forgot to add this: the contents.htm file is chmoded to 777 so any sollution? Last edited by andyxfun; 08-26-2009 at 08:19 AM.

Posted by mattle, 08-26-2009, 09:05 AM
Your problem is in str_replace(). Check the manual for proper usage (hint: what is the function's return value?). As for the whole "cheating" debate--when you come to us with pasted code and ask for "solutions" instead of help, you lose credibility when you argue that you are trying to learn...

Posted by petteyg359, 08-26-2009, 09:50 AM
That prevents crappy browsers that don't understand the