1

I have a script to export some data from SQL and format into Excel which is all working fine, for 3 out of 4 things I'm trying to export.. the final one is reporting the following :

Warning: fopen(/home/a/public_html/private/b/c/d/e/f/Martin's-g-23-11-2015.xls): failed to open stream: No such file or directory in /home/a/public_html/b/classes/Classes/PHPExcel/Shared/OLE/PPS/Root.php on line 90

This fine dose exist as this script worked fine for the other divisions just not Martin's. It also reports the following:

Fatal error: Uncaught exception 'Exception' with message 'Can't open /home/a/public_html/private/b/c/d/e/f/Martin's-g-23-11-2015.xls. It may be in use or protected.' in /home/a/public_html/b/classes/Classes/PHPExcel/Shared/OLE/PPS/Root.php:93 Stack trace: #0 /home/a/public_html/b/classes/Classes/PHPExcel/Writer/Excel5.php(233): PHPExcel_Shared_OLE_PPS_Root->save('/home/a/pu...') #1 /home/a/public_html/private/b/c/d/e/exportOther.php(66): PHPExcel_Writer_Excel5->save('/home/a/pu...') #2 {main} thrown in /home/a/public_html/b/classes/Classes/PHPExcel/Shared/OLE/PPS/Root.php on line 93

I'm stumped why this errors whilst everything else works, they all run off the same script so the fact its reporting permissions errors(?) is weird.. I've used htmlspecialchars for the name so Martin's shouldn't be effecting it and ufortunatly it has to be stored that way as it is captured from files provided to us.

Does anyone here know what is causing this error?

EDIT - printing out everything it decided to throw another random / before the Martin's when there shouldn't have been all sorted now sorry! (and thanks)

Adrocks__
  • 39
  • 6

2 Answers2

0

I can't comment yet so I had to post this as an answer:

Are you escaping the quote in Martin's, and cant you avoid having to use a quote in the first place?

Also, next time please post the code from your script that causes this error. We can only guess now.

jwebdev
  • 113
  • 10
  • I have done a string replace ($imprints=str_replace(" ' "," \' ",$imprints);) To replace the ' for \' to escape it but it doesn't seem to work, also unfortunatly I can't avoid using it at all as it is gathered from an external source provided to us to be added to our internal databases which requires the single quote to be there. – Adrocks__ Nov 23 '15 at 15:27
  • I'd manually do a fopen, adjust the path string until it works and work my way up from there. – jwebdev Nov 23 '15 at 15:40
  • We don't have any access to the sever (moving soon though so there is something..) However just got it sorted.. printing out everything it decided to throw another random / before the Martin's when there shouldn't have been all sorted now sorry! (and thanks) – Adrocks__ Nov 23 '15 at 15:44
0

The problem is in your filename. Maybe you are using fopen like this

 fopen('....Martin's...');

Please, don't use special characters in filenames. Try to avoid spaces, folder separators (\ /), spanish tildes and eñes, etc.

Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • I have done a string replace ($imprints=str_replace(" ' "," \' ",$imprints);) To replace the ' for \' to escape it but it doesn't seem to work, also unfortunatly I can't avoid using it at all as it is gathered from an external source provided to us to be added to our internal databases which requires the single quote to be there. – Adrocks__ Nov 23 '15 at 15:27
  • Share your code. We haven't got any crystal ball. Your declaration or your fopen function is wrong, so share your piece of code and we can help you. Otherwise we can only said pure speculation. – Marcos Pérez Gude Nov 23 '15 at 15:55