Get exclusive CAP network offers from top brands

View CAP Offers

Reply To: Click Tracking

[bsa_pro_ad_space id=2]
#693541
Anonymous
Inactive
TheGooner wrote:
I’m a newbie to PHP and MYSQL …
And have written a little bit now … only very simple stuff

Care to share the basic code and/or database design?
I’m sure you’ve already learnt and avoid some baisc pitfalls that I’d fall into.
:tongue:1. Most importantly, keep it as simple as possible.

2. Use the appropriate data types in your MySQL database — i.e. if you are storing numbers, use number fields; if you’re storing text, use text, etc.

3. Use only as much space as you need for each row, but be careful not to make the length of the field too short. i.e. if you set it to be only 8 characters long, and if you try to insert something larger than that, it will cut off the information after the 8th character.

4. When working with PHP code — if you use if/else statements, make sure to close the statements with a } symbol. I don’t know how many times I’ve tried to debug a script only to find that I forgot to close an if statement with a }.

5. If you are going to allow your visitors to put data in a form and then insert the data into your database, you definitely need to learn about “validation.” If you don’t validate the information someone enters into your form, they can potentially submit data that will corrupt the database. Example — they could enter a (apostrophe) into one of the fields. Seems harmless, but it could really screw things up. Or they could put =”; into a form field, or perhaps a line of php script. You have to make sure that the visitor can only send alphanumeric characters; or you have to use some php code to convert any non-alphanumeric characters into HTML entities before it hits the database.

Hope that helps a bit…. Obviously there is much more to learn; I suggest reading php.net and/or Kevin Yank’s tutorial about how to build your own database driven website.