Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    313
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Upgrading Old WordPress Site / Help with SQL queries not working

    Hi, I'm upgrading an old WordPress site from 3.7. It has a lot of SQL queries that don't seem to load anymore. I get the Content was not loaded die text. I was doing a bit of research and it is possible that after 3.9 you have to connect to the DB via their proprietary WPDB. I'm not really familiar with that. Could someone give me an idea how I could convert something like the following to work again?

    Code:
    <?
              $sql = "SELECT value FROM wp_acf_values WHERE wp_acf_values.field_id = '105' AND wp_acf_values.id = '234'";
              $result = mysql_query($sql) or die('Content was not loaded. Please refresh your page.');
              while($post = mysql_fetch_array($result)) {
    
                $sqlTitle = "SELECT meta_value FROM wp_postmeta WHERE meta_id = '".$post['value']."'";
                $result1 = mysql_query($sqlTitle) or die('Content was not loaded. Please refresh your page.');
                while($post1 = mysql_fetch_array($result1)) {
                  $spotlightTitle = $post1['meta_value'];
                }
    
              }
              ?>
    I came across this, is this the issue? https://make.wordpress.org/core/2014...wordpress-3-9/

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,119
    Thanks
    37
    Thanked 1,089 Times in 1,085 Posts
    Your using MySQL which is outdated. Learn and use either MySQLi or (and this is the more highly suggested of the two) PDO. Study them here https://www.w3schools.com/php/php_ref_mysqli.asp and PHP: PDO - Manual.

    Also note that the worpress get_var() works: https://codex.wordpress.org/Class_Re...ECT_a_Variable

    wordpress always go to other sites to learn it. https://easywpguide.com/wordpress-manual/
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •