sigmahokies Posted March 19, 2018 Share Posted March 19, 2018 Hi everyone, I am trying to make it simply, but seem error come repeatedly, I could not figure why it went wrong. I am trying to get print (echo) to visible the print before I build other script. but resilt said "Notice: Array to strong conversion in" what did I do wrong? Thanks, Gary <!doctype html><html><body><table><?php require("require2.php"); $show = "show tables from XXXX";$table = mysqli_query($GaryDB, $show);$array = array();while($array = mysqli_fetch_array($table)) { echo $array;}?></table></body></html> Quote Link to comment Share on other sites More sharing options...
archive Posted March 19, 2018 Share Posted March 19, 2018 You can't use echo for an array, try using print_r or var_dump if you do want to output the whole array. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 20, 2018 Share Posted March 20, 2018 You can't use echo for an array, try using print_r or var_dump if you do want to output the whole array. A lot of times a good way to do this type of thing is to assign the output of print_r to a variable and then use a pre tag. $output = print_r($array, true); //Where you want to see your output echo "<pre>$output</pre>\n"; Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 21, 2018 Share Posted March 21, 2018 ...assign the output of print_r to a variable and then use a pre tag. You could also output it all together. I typically use the following line, which I stole from someone here at PHPFreaks: print '<pre>' . print_r($array, true) . '</pre>'; Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 21, 2018 Share Posted March 21, 2018 Sure cyberRobot. I've seen people wrap that in a function as well that they include. The main point I wanted to make was that you can capture the output to a variable rather than just have it echo out wherever you are in the code. Sometimes this is helpful when you are trying to avoid messing up existing output with debug info. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.