Why can't deprecated mysql_* functions be used in PHP and what to replace them with?
Hello everyone! I'm a beginner PHP developer, learning from old textbooks and YouTube videos. In all examples, connecting to a MySQL database is done through mysql_connect(), mysql_query() and other functions. Everything works for me, but I noticed that modern tutorials don't use these functions. Moreover, PhpStorm underlines them in red and says "Deprecated".\n\nHere's how I currently write code:\n\n```php\n$link = mysql_connect('localhost', 'root', '');\nmysql_select_db('myblog', $link);\n$result = mysql_query("SELECT * FROM users WHERE id = " . $_GET['id']);\nwhile ($row = mysql_fetch_assoc($result)) {\n echo $row['name'];\n}\n```\n\nEverything seems to work, but I've heard it's dangerous. Can you explain in simple terms: why are mysql_* functions evil? And what should I use instead? I don't just need words.
No answers yet.
Log in to leave an answer