Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

kyuknis on "Whole Post Wont Show When Db Queried From PHP"

$
0
0

Greetings,

I'm trying to make a go-between for a WordPress site and a set of mobile apps for a client. The code I've been using so far (very early work in progress) has already encountered an issue. When I query the wp_posts table, it only returns part of the contents of the post in the post_contents column. I was wondering if anyone could offer any insight as to why this is?

Example of returned content vs actual content:
Returns:
"Pastor Jeff suggests in this talk specific things that we can do as believers each day. If you aim at nothing, you will hit it every time. We have to plan to be intentional. "

Actual content from website:
"Pastor Jeff suggests in this talk specific things that we can do as believers each day. If you aim at nothing, you will hit it every time. We have to plan to be intentional.

One of the things that he suggests on our journey toward intentionality is “TEXT TEN Thursday” This is intentional. It will require you to spend some time and thought. We want you to text ten of your friends every Thursday.

Send them a brief text letting them know that you are thinking about and praying for them. Being intentional means to encourage, to exhort and edify. You should make each text to each friend different. Do not be lazy and copy and paste…make the text special and from your heart."

The Query:
SELECT * FROM DbName.wp_posts ORDER BY post_date_gmt DESC;

The PHP code:

<?php

    // Create defintions for login data
    // The name of the database for WordPress
    define('DB_NAME', 'TheDatabasesName');

    // MySQL database username
    define('DB_USER', 'TheUserName');

    // MySQL database password
    define('DB_PASSWORD', 'ThePassword');

    // MySQL hostname
    define('DB_HOST', 'TheHostName');

    // Create connection
    $con=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    // Determine if connection was successful
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    // Get all of the data from the wp_posts table and order it by the date it was posted
    // DESC by post_date_gmt is for simpler interoperability with NSDate object from Foundation
    $sql = "SELECT * FROM DbName.wp_posts ORDER BY post_date_gmt DESC;";

    // Check if there are results
    if ($result = mysqli_query($con, $sql))
    {
        // Results array
        $resultArray = array();
        // Temporary array
        $tempArray = array();

        // Process for each row in the result set
        while($row = $result->fetch_object())
        {
            // Adds the row to the results array
            $tempArray = $row;
            array_push($resultArray, $tempArray);
        }

        // Finally, encode the array and output the results in JSON format
        echo json_encode($resultArray);
        }

    // Close connections
    mysqli_close($result);
    mysqli_close($con);
?>

The only thing I can think of at the moment is that post_content is only a segment of the post meant to be displayed on other parts of the website and the actual content is in another part of the database that I can not find. Thank you in advance for any assistance!


Viewing all articles
Browse latest Browse all 8245

Trending Articles