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

Attiq on "Access External Database"

$
0
0

I have retrive Data from external database using get_results function which is working fine on my local server but same code is not running on the online server it make an error like

Warning: Invalid argument supplied for foreach()in .....

my code is

<?php
    if (isset($_POST['submit'])) {
        $id = $_POST['userid'];
        $mydb = new wpdb('$dbusername', '$dbpassword', '$dbname', '$dbhost');
        $rows = $mydb->get_results("SELECT * FROM admin WHERE id=$id;");
        echo "<ul>";
        foreach ($rows as $obj) :
            echo "<li>" . $obj->username . "</li>";
        endforeach;
        echo "</ul>";
    }
    ?>

Viewing all articles
Browse latest Browse all 8245

Trending Articles