php addslashes etc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

First of, sorry for the attachment. It is a screenshot of the output of the 
following code. It also shows the contents of the array data in question.

I have the following piece of actual code:

<code>
// $arrayData is the data in an array form
$arrayData = ArrayIzeDbResult( $db2 ) ;

// we want to capture the printed output
ob_start();
$data = addslashes( serialize( $arrayData ) );
print $testdata;
$printeddata = ob_get_contents();

// this next line does not work since the results of unserialize 
// is bool(false)
ob_end_flush();
print "\nNumber, the first\n";
print_r( unserialize( stripslashes( $printeddata ) ) );

// however, this next line DOES work
print "\nNumber, the second\n";
print_r( unserialize( stripslashes( addslashes( serialize( $arrayData ) ) ) ) );
</code>

I am trying to store the serialized array into a database (mysql) but on 
reading it out again, it cannot unserialize. This piece of code, even though 
it doesn't use the db, shows the problem perfectly.

The other funny thing is that not all arrays break when I am doing this. I 
have quite a lot of similar arrays that work find when you do this. This one 
however needs to work too ;)

Regards,
Pieter Breed


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux