I'm learning PHP. From an old book at my university I first learned procedural PHP and MySQL, and then found out that both were not the "best" way of doing things. So, to keep learning, I start to modify some code I have based on procedural PHP and MySQL.

The problem comes that I am currently learning Object Oriented PHP, but, for studying a completely different degree, don't have much time. So I decided to first study OOP PHP and then, when the code is up and running, PDO (equivalent to MySQL but more secure and updated).

However, while I'm learning OOP PHP, I get some questions I cannot answer myself, and decide to come to Stack Overflow. The problem is that normally, while I have a specific PHP question, I get a variable number of comments saying please don't use mysql_* functions.

I know it's wrong, and I plan to change it before any kind of code goes into any kind of public testing. But, at the same time, to keep asking my questions and not to waste anyone's time, what do you recommend to avoid these kind of comments until I can fix it?

I normally put a disclaimer saying "shouldn't use mysql_*, use PDO instead", but it doesn't work. Similar situation is "don't reinvent the wheel", which I find convenient sometimes.

See an example here. I used a disclaimer in my code comments but still got some user to waste his time.

This question is definitely not top priority and only a small thing, but I would like to know the official view on this matter. Don't just answer "don't repeat your mistakes", I have reasons to do so as stated above.

  • Just for the record, you've added that disclaimer later, and I appropriately deleted my comment afterwards. Nov 4, 2012 at 19:58
  • The comment INSIDE the code was there before, but grayed out so not really that visible. That's my fault. Thanks for editing it. Nov 4, 2012 at 20:01
  • @FrankPresenciaFandos The code comment doesn't count as a disclaimer. Please make it crystal clear in the text of your question that you know what you're doing...
    – yannis
    Nov 4, 2012 at 20:06

2 Answers 2


Let me begin with this. The generic mysql_* comment is effective in general (I consider "effective" as "I've managed to educate a single user"). It's not only meant for you, but for visitors seeing your code, in order for them to learn it's not good practice to do what you do there.

If your eyes were already opened, good for you! That doesn't mean everyone else's are.

Despite That

Should you have placed a disclaimer at the top, with something similar to:

I know about the use of mysql_*, this is old code. I know I shouldn't use it

No comments should[1] be placed.

1: should because some people would still blindly paste the comment. I try very hard not to.

As for reinventing the wheel. Re-inventing the wheel is perfectly acceptable in many cases.

  • You want to learn about "teh wheel", and improve yourself in the process.
  • You don't assume "teh wheel" to be perfect, and improve "teh wheel" in the process.

After all, "teh wheel" wouldn't have been a very good one, unless it was being reinvented and improved over and over again!

  • 1
    I was just about to post this but as the original commenter it's more appropriate if you do. The only think I would have suggested differently is that actually posting your comment on this question (including links) is better than the "Note" part. Nov 4, 2012 at 19:59

Several regular PHP users are posting comments like the one Madara Uchiha posted:

I know this is old code, but just for general knowlege: Please, don't use mysql_* functions in new code. They are no longer maintained and the deprecation process has begun on it. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

This is a good comment, and it's part of an effort of the wider PHP community to raise awareness for the (currently soft) deprecation of mysql_* comments. I get where you're coming from, but personally I think you should be happy that there are several users within the SO PHP community that are trying hard to help newer PHP developers avoid a common pitfall.

Furthermore PDO is not the only alternative given, if you don't want to trouble yourself with object orientation right now, you should look at mysqli_* functions (notice the extra i), that offer a drop in replacement procedural interface. Also re-inventing the wheel can be extremely valuable when learning, and may lead to different answers if people take into consideration that you are doing it willingly. Please make it crystal clear in your questions that you know what you're doing, you can't really expect us to guess.

Lastly, these comments are not just for you, but for potentially everyone who will happen upon your question in the future. If they annoy you that much, you can simply ignore them.

  • I'm happy for that. I just wanted to know how to properly indicate it myself if I know that there is a mistake, instead of making other user to put it. Now it's more clear for me. Nov 4, 2012 at 20:06
  • 1
    @FrankPresenciaFandos: I've edited your original question on Stack Overflow. That is a proper, (clear) disclaimer. The first one wasn't obvious. Also, putting it at the top of the question is also a plus :) Nov 4, 2012 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .