I'm new to PHP, how many mistakes am I making?(github.com)
github.com
I'm new to PHP, how many mistakes am I making?
http://github.com/inoads/The-Queue
With no prior experience writing code in PHP, please let me know how to improve and what to look into next. Live: http://api.inoads.com/snowstorm/
3 comments
Try the Code Review StackExchange - this is hardly the right place for your post.
Your only mistake is learn PHP. Learn Ruby or Python, you''l better off on a job market (if that is your goal).
PHP is an astonishingly inept language with an inexhaustible supply of WTF, but not necessarily a bad short-term career move. I think the industry might see a mini-COBOL phase as some really flaky yet successful legacy PHP needs to be maintained and finally replaced, and nobody smart wants to deal with it without being paid well. You'd definitely want to stay sharp on something better, though, both for sanity and to remain employable long-term.
htmlspecialchars() is for html sanitation. For the sql in insert.php you will want mysql_real_escape_string().
insert.php writes to the database. You may want to wrap that inside some kind of session checking so that only logged-in users are allowed to run the insert. As it is now, anybody could send parameters to the script and it would run an insert.
You may also want to create some protection against a double-insert.
"break" is repeated in index.php characterData() case TITLE. This won't cause any problems but it reminds me that PHP lets you say "break 2" to break out of two layers of looping, if you ever need to do that.
insert.php writes to the database. You may want to wrap that inside some kind of session checking so that only logged-in users are allowed to run the insert. As it is now, anybody could send parameters to the script and it would run an insert.
You may also want to create some protection against a double-insert.
"break" is repeated in index.php characterData() case TITLE. This won't cause any problems but it reminds me that PHP lets you say "break 2" to break out of two layers of looping, if you ever need to do that.