0

There is some data is stored in my sql table. I want to fetch the data in the form of string.

$sql= "SELECT hash FROM signupinfo WHERE fname = 'nikhil';";
$hashfix = mysqli_query($connection,$sql); 
echo $hashfix;

but the error coming

Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\WampDeveloper\Websites\localhost\webroot\signup.php on line 48

Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

0

var_dump($hashfix). If you want to read your array all Data fetched from a db come in the form of array

Its not a good idea to echo array...by that I mean you can't. What you can do in to make a string is. $a=implode(',',$hashfix)

There are 2 ways to print values you want

If its a single key array.
echo $hashfix[0]->ColumnName

Or run a foreach

Reuben Gomes
  • 878
  • 9
  • 16
0

You could do something like this...

$sql= "SELECT `hash` FROM `signupinfo` WHERE `fname` = 'nikhil';";
$hashfix = mysqli_query( $connection, $sql ); 
if( $hashfix ){
    while( $rs=$connection->fetch_object( $hashfix ) ){
        echo $rs->hash;
    }
}
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46