// ITERATE OVER A RESULTS SET, RETURNING EACH ROW IN THE FORM OF AN OBJECTwhile($show_columns=$query->fetch_object()){ // ASSIGN THE VALUE OF THE OBJECT->Field PROPERTY TO A STRING VARIABLE, OVERWRITING IT EVERY TIME $the_columns=$show_columns->Field;}// RETURN THE STRING VALUEreturn $the_columns;

What you more likely wanted was something like this. The empty square brackets are PHP array notation meaning, "Add a new element to the array."

// ITERATE OVER A RESULTS SET, RETURNING EACH ROW IN THE FORM OF AN OBJECTwhile($show_columns=$query->fetch_object()){ // ASSIGN THE VALUE OF THE OBJECT->Field PROPERTY TO ELEMENTS OF AN ARRAY, APPENDING A NEW ELEMENT EACH TIME $the_columns[]=$show_columns->Field;}// RETURN THE ARRAY OF COLLECTED STRING VALUESreturn $the_columns;

...but I'm wrong. I get an error that says: "Trying to get property of non-object in C:\wamp\www\sandbox\csv_upload.php on line 127" (line 127 being $rows=$columns->the_columns) and another error that reads "Invalid argument supplied for foreach() in C:\wamp\www\sandbox\csv_upload.php on line 129," which I'm assuming is the logical result of the shortcomings represented by line 127. How do I accurately "unpack" the array as it's being supplied by my function?

Featured Post

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Originally, this post was published on Monitis Blog, you can check it
here
.
In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…

The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…