If you use your code in the same way as this, then it is vulnerable to SQL Injection. I highly recommend using mysql_real_escape_string when pasting data into your database to prevent SQL injection as a quick fix or it is better to use PDO or MySQLi .
If you intend to use mysql_* , I would recommend reading the chapter of the PHP manual on mysql_* functions where they indicate that this extension is not recommended for writing new code. Instead, they say that you should use either MySQLi or PDO_MySQL .
I also checked mysql_connect and found a strange regularity, which is - if you use the arguments on mysql_connect , then it cannot connect, and in my case, when I tested it, it was just described, try instead:
$con = mysql_connect('localhost','username','password');
Replace " with ' , as shown in the PHP Manual examples, and it might work!
EDITED
For those who do downvote - TRY first! I tested it on my server using " and it gave me an error: Warning: mysql_connect(): Access denied for user . I am using PHP version 5.4.6!
Log in to your server with SSH and run php --modules - if you do not see mysql in the list then this is the cause of your fatal error.
source share