0

I have a form contains many text box,checkbox,radio etc.

for the posting page i used var_dump to capture result.

I need to store the result of var_dump in mysql . Is it possible?

1 Answers1

2

It's perfectly possible, just not generally wise to do so. var_dump() is generally used as a tool for debugging, not as a data storage format; var_export() will give you the same format, but returning it as a string that can be stored rather than simply displaying it to screen.

Your problem will be trying to do something with the data subsequently, because it's a format that's not easily reversible: you'll have problems trying to parse it back to the original form variables.

You might instead want to consider using json_encode() or serialize() instead, both of which are reversible formats, making it easy to restore the original data in a form that a script can then work with again.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • i used var_export($_POST).How to store the result of this in a mysql table – Sandeep Vellaparambil Feb 16 '15 at 08:36
  • 1
    `How to store the result of this in a mysql table` Do you know how to write data to a MySQL database at all? Look at functions in the php docs like the [MySQLi functions](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php), and read some of the examples there, paying particular attention to prepared statements and bind variables – Mark Baker Feb 16 '15 at 08:37
  • The result is like this array ( 'color' => 'red', 'm_status' => 'yes', 'c_status' => 'yes', 'b_status' => 'yes', 'hobies' => array ( 0 => 'games', 1 => 'reading', 2 => 'writing', 3 => 'internet', ), ) – Sandeep Vellaparambil Feb 16 '15 at 08:39
  • I need to store this as exactly same in a table column – Sandeep Vellaparambil Feb 16 '15 at 08:40
  • Have you looked at the link I posted to working with MySQLi? HAve you written any code to try and store the data? Have you created a database to store the data in? – Mark Baker Feb 16 '15 at 09:02