Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:17:53+00:00 2026-05-25T15:17:53+00:00

My program originally called a mySQL query over http. The result was returned in

  • 0

My program originally called a mySQL query over http. The result was returned in JSON form:

 $query  = "SELECT xaxis, yaxis FROM table ";
$result = mysql_query($query);

$rows = array();
$counter=1;

while ($r = mysql_fetch_array($result, MYSQL_NUM))
{

     echo json_encode($r[0]), "\n";
     echo json_encode($r[1]), "\n";

    $counter++;

} 


?>  

It works ok (granted not the best PHP script in the world), but now I’m doing everything in SSH and I was thinking about doing the SQL query through bash and then I thought, why don’t I just call the PHP script in SSH?

However I’m not sure how to do this, given that the PHP returns an array. If it returned a simple file I could, in theory just do:

spc username@hostname:filename  localfilename

How should I return get an array from a script in SSH?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:17:53+00:00Added an answer on May 25, 2026 at 3:17 pm

    The PHP does not return an array. It returns a JSON-format string: remember, HTTP can only ever give you text.

    So there is no difference. Just invoke the PHP script in your terminal and you’ll see the same text.

    (Actually, it looks like you have two distinct JSON structures, separated by a newline. You might want to fix that by encoding $r instead:)

    [user@host: ~]$ cat myscript.php
    <?php
    $query  = "SELECT `xaxis`, `yaxis` FROM `table`";
    $result = mysql_query($query);
    
    $rows = Array();
    while ($r = mysql_fetch_assoc($result)) {
         $rows[] = $r;
    }
    
    echo json_encode($rows);
    ?>
    
    [user@host: ~]$ php myscript.php
    [
       { "xaxis" : 0, "yaxis" : 0 },
       { "xaxis" : 3, "yaxis" : 2 },
       { "xaxis" : 8, "yaxis" : 5 }
    ]
    

    Or something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan
I am making a win32 api program. I first created a base class called
I'm trying to use a Singleton Class (its a program-wide debug logger called 'PrisLog')
I'm trying to write myself a program that calculates a function taken from a
I have a fairly old unmanaged C++ program that called managed c# code (vs2003)
I have a program, written in Java, which originally used its directory in Program
I have a multi-threaded program, where I have one thread to watch over several
I'm implementing part of a Scala program that takes input strings of the form
I've noticed that every running C program has a private mapping called [stack] that
The folowing program was orignally in java. But i still get 1 error with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.