Code snippet examples

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Is it me or do the same questions get asked again and again??

I thought a forum with code examples might be beneficial so users can just pick out what they need - rather than googling which some users find very tricky ;).

Or would it be better just to have a sticky in this forum category?

It might also be useful for new ideas.

Common issues include

"how do I create a login page"

"how do I create a registration process"

"what code do I need to make a connection?"

I know these have already been created a thousand times (and google/ sourceforge would solve a few) but there's nothing here that I can see.

For example, I have just figured how to create a dynamic event calendar month and day view - completely driven by php (no Javascript) and linking to three relational tables.

I'm sure there are many more.

Just to clarify, I'm not talking about tutorials (already here!) but simple code examples that can be cut and pasted into existing script.

What are your thoughts?
 
Last edited:

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
I think this would be very good - I'm sure many people new to PHP/MySQL would find it useful. :)
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
I too am in agreement.
However, due to past experience we may only see a slight decline in the number of questions. On a previous board, there was a sticky named FAQ: Here's how to make a login page. You don't want to know how many topics I saw asking how to make a login page even with that there. *shudders*

But still, let's give it a go! :D
 

FalseHope

Active Member
Messages
1,639
Reaction score
0
Points
36
Yeah, this would be perfect for beginners. Even a good reference guide for anyone else too.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
I wouldn't have thought adding this as an additional category here would be too much of a problem.

Admin - is this something worth checking out?
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
I'd say it is a nice idea but most people who asks thinks that their problem is unique. That would be why they will still ask anyway even if the question should have been answered at least a thousand times. :)
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
What might work just as well is some kind of prompt about "CHECK W3SCHOOLS FIRST" as 9 times out of 10 all newbie questions can be answered with that statement.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
What might work just as well is some kind of prompt about "CHECK W3SCHOOLS FIRST" as 9 times out of 10 all newbie questions can be answered with that statement.

My issue with this - as you know yourself - is that they don't!

In addition, may questions don't really want help understanding what they are writing, they want it done for them!

I have recently been posting back and forth for a user (who shall remain nameless) on a thread that is now about 7 pages long on a fairly simple exercise. :nuts: On page 7, I am having to reference back to page 1 and its starting to do my head in...:mad:

Code snippets would eliminate much of this as the user can "cut & paste" without really having to understand much - I know this goes against the principle of this particular forum, but it should be a valuable resource.

Isn't this what a lot of WYSIWYG editing programs do anyway (DW for example)?
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
But how valuable will it be, really? I've seen several users complain about errors which have been caused because they don't understand the code so don't think they need to change YOUR_USERNAME_HERE and YOUR_PASSWORD_HERE or DATABASE_NAME. "What's my database name?" has been posted so many times that I'm going to start choking people if I see it much more.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
But how valuable will it be, really? I've seen several users complain about errors which have been caused because they don't understand the code so don't think they need to change YOUR_USERNAME_HERE and YOUR_PASSWORD_HERE or DATABASE_NAME. "What's my database name?" has been posted so many times that I'm going to start choking people if I see it much more.

LMAO

I do agree with you and would ask if you think this forum concept would be a good starting point - even if it does need amending afterwards.

To be honest, I'm not trying to argue a point; just canvass opinions.

If the opinions are strong, I think site admin should take a look.
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
I'm all for it. Never know, if Google indexed it we might end up getting a few people here who actually know a thing or two :)
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
I'm all for it. Never know, if Google indexed it we might end up getting a few people here who actually know a thing or two :)

Might even pinch David Powers from the Adobe forums! (if anyone even knows who he is lol)

It would certainly increase ranking and hits.
 

epoclaen

Member
Messages
79
Reaction score
0
Points
6
Code snippets remind me of most function calls that are used in my company's programming scripts. That is, they can be klunky and sometimes hard to understand for users who aren't already at least familiar with the basics of the programming language and this often leads them to make amateur mistakes.

I've also seen some that are so fantastic and straight-forward in describing how to use the function that even people who have no programming experience can use them without confusion!

My point is that yeah, this is a fine idea but the snippets would have to be clearly documented for it to succeed.

Pointing users to resources like W3SCHOOLS is good if coders want a more thorough understanding of how a code snippet works and/or how they can modify it to suit a unique need but in general telling them to check there often subjects them to more information than they care to have to search for, read through, and understand comprehensively. Sometimes they're just too inexperienced and dropping the code in front of them with an optional link to W3SCHOOLS is all you can do.

I think calling the thread something other than "FAQ" might drawn more people to reading it. Calling it "Quick Code Snippets" or something might be better.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Code snippets remind me of most function calls that are used in my company's programming scripts. That is, they can be klunky and sometimes hard to understand for users who aren't already at least familiar with the basics of the programming language and this often leads them to make amateur mistakes.

I've also seen some that are so fantastic and straight-forward in describing how to use the function that even people who have no programming experience can use them without confusion!

My point is that yeah, this is a fine idea but the snippets would have to be clearly documented for it to succeed.

Pointing users to resources like W3SCHOOLS is good if coders want a more thorough understanding of how a code snippet works and/or how they can modify it to suit a unique need but in general telling them to check there often subjects them to more information than they care to have to search for, read through, and understand comprehensively. Sometimes they're just too inexperienced and dropping the code in front of them with an optional link to W3SCHOOLS is all you can do.

I think calling the thread something other than "FAQ" might drawn more people to reading it. Calling it "Quick Code Snippets" or something might be better.

This is a very valid point and the entries in this potential forum will only be as good as the detail of the entries - much like the "Tutorials" forum here.

I have to admit, for the unexperienced, you are right in saying that many will not have the inclination to thoroughly read through and understand the complete script. In my earlier years (and now!), this was the case and I found myself getting very mixed up when the code didn't work for whatever reason.

xmakina made this point earlier when referring to simple things like connection scripts where some users won't even know how to replace certain variables with their own values.

e.g.

PHP:
$newvalue=crypt(yourvaluetoencrypt);

Maybe a top sticky, explaining how certain parts are to be replaced would be useful

Like

PHP:
$newvalue=crypt(^change this variable^$yourvaluetoencrypt^end change variable^);

or some other "commented out" system other than the standard // or /* etc.
 

natsuki

New Member
Messages
112
Reaction score
0
Points
0
I hope people at least POST THE ERROR MESSAGE/S they are getting when they are asking for help. After all, it's just a simple copy/paste. It usually is easily solved by just knowing the error. PHP errors aren't as cryptic as C++'s error messages. Unless of course there no error to post. lol

Can't we make a thread that says "Always post the errors you're getting when asking for help." even if the thread itself doesn't contain anything.
 
Last edited:

xmakina

New Member
Messages
264
Reaction score
0
Points
0
You know what might work? When a user is about to post in here for the first time, they recieve a STOP! Wait! message, with a copy of the "How to ask for Programming Help" included. They have to tick a box saying they've read and meet these guidelines before posting. Would give us a good reason to throw out people too freaking lazy to even ask properly for help.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Without admin support and the will to alter the forum slightly, I'm afraid none of this is relevant!! :nuts:
 
Top