There are three different interfaces currently available to communicate between PHP and MySQL.
mysql_ which is currently obsolete and will be deleted from the next version of PHP mysqli_ which is the improved direct replacement PDO which offers a database independent interface (and which supports databases other than mySQL allowing switching databases to be done much easier)
You should currently be using either the second or third of these - there’s no reason to switch from mysqli_ to PDO unless you expect to switch away from MySQL. Any mysql_ use that you currently have should be converted to one of the other two as soon as possible.
I wanted to build a site which I have almost completed however I built the site in MySQL as per below. The problem I have now is that people are telling me that it should be in PDO. The problem is I am finding it very hard to get to grips with PDO. Much harder than MySQL.
For example if this is going to become deprecated how can I update it into PDO?
<?php
$query = mysql_query("SELECT eventname, firstname, eventdetails, eventlocation, eventcountry, eventid, eventstart, eventend, logo, company, id, supplierdetails1, eventid
FROM users
JOIN eventjobs ON eventjobs.organiserid = users.id
ORDER BY eventid DESC
LIMIT 8 ");
while($row = mysql_fetch_array($query)) {
?>
I’d disagree that there’s no reason to switch from mysqli_ to PDO unless you which to switch away from mysql for one reason - it has better prepared statements than the mysqli_ functionality, because it can accept named variables in prepared statements.
For the original poster: prepared statements are much more secure than writing a standard sql query and relying on mysqli_real_escape_string and other such functions, and while both the mysqli_* library and the PDO library support this functionality, it’s better in PDO and I’d therefore recommend PDO for this reason.