While this can be Googled, I want to explain the answer to the asker, and allow future readers to understand this question easily.
Deprecated code doesn't necessarily mean the code won't work. It indicates that it is no longer supported.
Now in theory, you can just go and put an @
in front of the function and the error won't appear. Now I recommend you NEVER DO THIS in a working environment. It exists to suppress warnings, but it still means you have security weaknesses. All php functions that express mysql_functionName()
are outdated (or deprecated). To fix this, use something along the lines of mysqli_functionName()
instead.
Using mysqli allows you to stay up to date. Now I see you are using procedural styling. This is allowed, but it is recommended that you use object-oriented-programming or PDO. I personally use OOP-mysqli.
Now it should be noted that it is not a seamless transition; meaning you cannot simply just add the i
in mysql
. Functions such as mysqli_connect()
are different. mysqli_num_rows()
on the other hand should handle the same by just adding the i
in mysql
. Check the Mysqli Documentation here for more info on the transitions.
To be more elaborate:
This are nearly the same:
mysqli_num_rows()
These are different:
mysqli_connect()
, mysqli_real_escape_string()
This is removed
mysql_result()
(There is no built in equivalent in mysqli
).
I hope this answer was elaborate enough for you.
EDIT:
Based on the question asked by the asker, it is not possible to combine both mysql
and mysqli
together. They are different calls to the database. If you call a mysqli_connect()
, the variable you set it to is connected to that db call. It will only recognize mysqli
. A lot of functions in mysqli
such as mysqli_real_escape_string()
and mysqli_query()
require you to pass the connection of the original db call.
In conclusion, don't try to mix calls. It won't work and it has a lot of security issues and flaws.
It is my opinion that one should completely rewrite their code when the entire infrastructure changes, since it is safer to not risk any old code that might have been left behind in edits. This of course has a major flaw; being it means having to work super hard to rebuild. It is up to the user in this case depending on the size of the project.