darkangel2001lv;11018791 wrote:
I am still learning
which is fine... that's what this board is for
darkangel2001lv;11018791 wrote:
and half of what you are saying I don't understand what you are talking about
Then it's smart to ask questions. Smarter yet to ask specific questions. With a little more feedback, back to the trial and error, trial and success stage of coding. Use lots of output to examine what's in which variables, which if condition is true and what code is executed. In this stage, it doesn't have to be the output it should produce in the end - the output would be there for your benefit to learn what happens. Then you post back here, get to read some more you don't understand half of. Ask another specific question...
darkangel2001lv;11018791 wrote:
I research everything everyone is saying to try to understand it. How about instead of ripping at me for what I did wrong you explain it to me in plain English.
Actually, the first part seems to be a lie when we examine your indentation later on. Chill, I said "seems to be". I realize it's because you missed out on the importance of one thing, while focusing entirely on "being ripped on". But I digress.
The first thing you did wrong here was the last sentence. You are way off in your interpretation of what's going on. And no, that wasn't ripping on you either. You are also focusing entirely on the wrong parts. Well, focusing on any one part is usually wrong when it comes to replies here. Since the posts are written to help you, I strongly recommend you "focus" on all parts. Anything else is stupid (the way I feel about it and the way I read posts when I'm asking the questions - not ripping).
Weedpacket;11018789 wrote:
It's something you should have thought about before you started....
Not sure if this is what you felt was "ripping" on you, but it really isn't. This is basic advice about any programming process. And it is very very sound advice indeed. Does it imply that you didn't think it through? Possibly. Does that make you feel like a fool? Well, that really is your problem not ours. And please note that there is no reason to feel like a fool. You're just starting out - remember. You don't understand half the things you read here. Remember? Taking in that much information at once is overwhelming. Thinking things through in advance when you have no idea what things to think through... impossible (but still worthwhile TRYING to do).
The point is: when you've learnt some more - think it through AGAIN. Yes, in some circumstances it's even easier to start over AGAIN, rather than keep trying to correct flawed design. And NO, I'm NOT saying that you should neccesarily start over.
Weedpacket;11018789 wrote:
it's a matter of having to think logically and writing a program so that it works in a sensible way even when circumstances aren't perfect (such as when search terms aren't entered, or there are no results).
Still not ripping at you, even if you apparently feel like a great "logic thinker" from what you wrote in your reply. Me personally, I'm not really interested in what you are saying, and neither should you be, as long as you're the one asking the questions. Let's instead move on to the (hopefully) obviously non-ripping-comment preceeding the ones that most likely ticked you off and drew your attention...
...namely this little gem
Weedpacket;11018789 wrote:
Formatting your code would make it easier for you to read.
Now, you missed the most important advice in weedpackets response, so I'll point out three very general things this once:
1. People usually will not put things in red, caps, bold etc to make you understand that they are important. But if they did, "Formatting your code would make it easier for you to read" would be RED BOLD ALL CAPS.
2. If something seems unimportant, yet someone took the time to write it in a response to your question, it's always smarter to assume it's very very important than trying to find "the holy grail sentence" in the reply (hint: there usually is no one such sentence).
3. Before you respond to a previous post, especially to make accusasions of any kind, make very sure that you've tried all their advice - even indentation.
Notice how 2. and 3. contained nothing red, bold or in caps? If you think they were not important, read 1. again. Also note how 3. (trying something out) would usually lead to you learning the facts behind 2. (how important it really is), as long as you started out by adhearing to 2. (not writing it off as unimportant in the first place).
Also note that when I said "the most important advice", I only mean that at the specific point your code is at right now... And let's get around to seeing why! I decided to try out weedpackets advice and indent your code. Not only did I notice some very interesting problems about the code as such, but the very first thing I noticed was that you don't even use one single way of indenting your code.
1. IMPORTANT: Do just that. It doesn't matter if it's K&R, BSD, GNU or some homecooked style. What matters is consitency!
This is not consistent
if ($condition) {
#code
}
else
{
#code
}
And neither is this
if ($condition)
{
#code
}
else
{
#code
}
while this is
if ($condition)
{
#code
}
else {
#code
}
Just like to add one more thing before we look at the indented code
darkangel2001lv;11018791 wrote:
And it still doesn't work.
When you say "doesn't work", it would seem to mean, "the code doesn't run at all", rather than "my pagination doesn't work the way it should". There is a big difference between the two. If the code doesn't run at all, you'd be better off letting people know to begin with, since it's then easier for those helping out to find the error.
if (isset($_GET['SearchTerms']))
{
$SearchTerms = trim($_GET['SearchTerms']);
$SearchTerms = strip_tags($SearchTerms); // remove any html/javascript.
}
if (strlen($SearchTerms) < 2)
{
echo " Your search term must be more than 2 characters. Please try again.";
{
if ($searchTerms == "")
{
echo "<p>You forgot to enter a search term";
}
}
} # ERROR! And this is a parse error... your script won't run
else
{
$SearchTermDB = mysql_real_escape_string($SearchTerms); // prevent sql injection.
}
Apart from this code not being able to run at all, if it did and I didn't enter a search term, I'd get to see both
"Your search term must be more than 2 characters. Please try again."
and
"<p>You forgot to enter a search term"
Now, this is simply a matter of superflous and possibly confusing feedback messages, unless of course we count the crappy markup (the first NOT being a paragraph, while the second is, along with the fact that the second line doesn't close it's paragraph, which will be a problem if the following output doesn't open a new one).
Still, you actually go ahead after and query the database after you checked and found out that there is no point.
Why? There really is no point.
Plausible answer: because you didn't see that this was happening, due to faulty indentation
darkangel2001lv;11018791 wrote:
I know my code is not right that is why i am here for help.
You might have also known why it didn't work, had you tried the indentation "trick" weedpacket gave you advice about. But perhaps you were busy telling him he was ripping on you and shouldn't do that?
Also, when you get an error message, please include that when posting.