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

  • SEARCH
  • Home
  • 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 8334475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:21:57+00:00 2026-06-09T03:21:57+00:00

Possible Duplicate: Output (echo/print) everything from a PHP Array I have done a query

  • 0

Possible Duplicate:
Output (echo/print) everything from a PHP Array

I have done a query from a database and the result is stored in a variable which is believe is an array. The output is only one row and column so i use:

echo result[0];

to output the result.
However i get an error saying:

Notice: Array to string conversion in "C:/apache/htdocs...."
array

I tried to dump the variable using

var_dump result[0];

I then get this

array(1) { [0]=> array(1) { ["var_datain"]=> string(4) "hai!" } } 

So…. how do i get it to echo out the value hai! from that array?

In case it matters, here is my query

    $db = new PDO(DSN, DBUSER, DBPASS);
    $stmt = $db->prepare("CALL test(?)");
    $parameter = 'hai!';
    $stmt->bindValue(1, $parameter, PDO::PARAM_STR);
    $rs = $stmt->execute();
    $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    var_dump($result);
  • 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-06-09T03:22:00+00:00Added an answer on June 9, 2026 at 3:22 am

    It’s a multidimensional array.

    echo $result[0]['var_datain'];
    

    It depends of the way you did your query (show us more code to explain you better) but it looks that in your case each line returned by your query is another array containing the columns that you selected. Even if you select only one col and only one row, it’s still returned as a multidimensional array.

    Got it?

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

Sidebar

Related Questions

Possible Duplicate: Running a command from Ruby displaying and capturing the output I have
Possible Duplicate: How to parse HTML with PHP? Get MySQL database output via PHP
Possible Duplicate: PHP : Create array for JSON I need to output data in
Possible Duplicate: Reference: Comparing PHP's print and echo I am wondering about the practical
Possible Duplicate: PHP XML how to output nice format I have the following PHP
Possible Duplicate: PHP htmlentities() on input before DB insert, instead of on output For
Possible Duplicate: PHP unexpected result of float to int type cast int((0.1+0.7)*10) = 7
Possible Duplicate: Get output from a process Executing DOS commands from Java I am
Possible Duplicate: How do you get assembler output from C/C++ source in gcc? Hello
Possible Duplicate: SQL Server Full text Index SQL Server stored procedure parameter output I

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.