Thanks Daniel for your suggestions. What I have found are: 1) I'm assuming the key is good. A value of 1947143245 is returned. 2) I have set the permission of the shared memory ("program.SCShared") to 777 octal (full read/write/execute access). The group and owner of the file is my login ('eclipse'). According to the PHP manual for shmop_open(..), I do not need to set the 'mode' parameter of this function (eg, to 0777) because I'm trying to connect to an existing shared memory block. Despite this, I've tried setting mode=0777, but errors were generated when I ran the code. I event tried changing the user and group to 'www-data' with no luck. 3) I added the debug_backtrace and the display result was "array(0) {}" inserted where debug_backtrace() was added as shown, but I'm not sure what the result really means: ========CODE============ <?php $shm_key = ftok("/dev/shm/program.SCShared", 't'); var_dump(debug_backtrace()); if ($shm_key < 0) { echo "\nftok failed. Error message is $php_errormsg <br>"; } $shm_id = shmop_open ($shm_key,"w",0,0); if ($shm_id == FALSE) { echo "\n Shared memory doesnt exists <br>"; } else { echo "\n Shared memory exists <br>"; } $shm_size = shmop_size ($shm_id); var_dump(debug_backtrace()); echo "\n the size of shared memory is $shm_size <br>"; $shm_data = shmop_read($shm_id, 0, 32); if ($shm_data == FALSE) { echo "\nCould not read data. : $php_errormsg <br>"; } else { echo "\nRead successful <br>"; } echo "\n read1 is $shm_data <br>"; $shm_data = unserialize($shm_data); echo "\n read2 is $shm_data <br>"; $i = strpos($shm_data, "\0"); if ($i === FALSE) { echo "\n String is NULL <br>"; } else { $result = substr($shm_data, 0, $i); print_r($result); echo "<br>"; } shmop_close($shm_id); echo "\nDetached from shared memory"; ?> ========================= =======RESULT OF CODE==== array(0) { } Shared memory exists array(0) { } the size of shared memory is 10000 Read successful read1 is PHP_SM�&' read2 is String is NULL Detached from shared memory ========================= 4) The data I expecting to read is "9876.54321" because this is the first string in memory. A 'cat' of the shared memory is shown: root@ts7800:shm# cat program.SCShared 9876.5432101.2300000034.500000678.9010002345.678900 5) Is there anything else that can try? Regards, Richard. On Thu, May 21, 2009 at 11:17 PM, Daniel Brown <danbrown@xxxxxxx> wrote: > On Thu, May 21, 2009 at 10:15, Richard W <rw180273@xxxxxxxxx> wrote: > > > > Any help will be greatly appreciated, especially answering 2) as to why I > > can't read the data. > > Are you certain that the problem lies within the shmop reading? > Check to see if the file is actually being accessed properly, the key > is good from your ftok(), etc. You may also want to make sure that > things as basic as permissions and 'who created' vs. 'who can read' > (since you're trying to run it from the web server) match up > appropriately. > > With just a cursory glance, the shmop_read() piece itself looks > fine, which suggests to me that there may be other problems. See if > the logs spit anything out, or try to debug the things with an `or > die("Here's the error.\n");` tacked onto the end of the suspected > lines. If it's crashing out, consider a cachegrind or > debug_backtrace() run. > > As for the memory being read, I'd agree that it does seem that it > is, since shm_open() is returning something other than FALSE, but that > doesn't mean that it's `=== TRUE` either. It may instead be returning > a message or another unexpected result that, in empty(), may evaluate > to TRUE and allow it to echo out the message in your test condition. > > -- > </Daniel P. Brown> > daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx > http://www.parasane.net/ || http://www.pilotpig.net/ > 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000 >