0

I'm following a tutorial online but I think it's slightly outdated or they're using a different program so I just need help converting the below SQL code into a version PHP can understand.

$req1 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, st_accounts.id as st_accountsid, st_accounts.username from pm as m1, pm as m2,st_accounts where ((m1.user1="'.$_SESSION['st_accountsid'].'" and m1.user1read="no" and st_accounts.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="no" and st_accounts.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');

$req2 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, st_accounts.id as userid, st_accounts.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="yes" and st_accounts.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="yes" and st_accounts.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
O Sparks
  • 43
  • 1
  • 9
  • 4
    Possible duplicate of [Call to undefined function mysql\_query() with Login](https://stackoverflow.com/questions/39493105/call-to-undefined-function-mysql-query-with-login) – dparoli Mar 01 '19 at 23:22
  • Slightly outdated is an understatement... [mysql_query](http://php.net/manual/en/function.mysql-query.php) -- see the pink section there -- was deprecated as of PHP v5.5 (20 June 2013), and fully removed in PHP 7.0. So, it's now pushing 6 years ago when the deprecation started. That being said, check the PHP docs for [mysqli_query](http://php.net/manual/en/mysqli.query.php), the change is not that bad, but it does differ `slightly`. Example usage is shown as well. – Paul T. Mar 02 '19 at 06:29

0 Answers0