Search code examples
phpmysqlcurlrow

Getting mysql row using curl


Ok, so am trying to fetch mysql row from remote server database by posting 2 fields, member id and secret code

    if(isset($_GET['uid'])){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.mysite.com/get_user_info/index.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, true);
    $data = array(
        'member_id' => $_GET['uid'],
        'secret' => 'secret'
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    $output = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
}

on the remote server /get_user_info

i have this

    $query = mysql_query("SELECT * FROM user_data WHERE user_id = '$_POST[member_id]'");
    if($query){
        $row = mysql_fetch_row($query);
    }
print_r($row);

so am trying to fetch that user info row from mysql using curl, but i get just text

so how can i get usable php array, so i can do like <?php echo $output['name']; ?>


Solution

  • On the remote server

    echo serialize( $row );
    

    in your first script

    $array = unserialize( $output );