Page 1 of 1

[SOLVED] Problem with escaping quotes PHP

Posted: 2010-12-06T15:47:04-07:00
by brianatlarge
For some reason, the following code works fine in the command line:

Code: Select all

/usr/local/bin/convert /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/car01.jpg -font Helvetica-Bold -pointsize 50 -draw "gravity center fill black text 1,12 'SOLD' fill red text 0,11 'SOLD' " sold.jpg
But in my PHP script, I've got this line:

Code: Select all

exec("/usr/local/bin/convert /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/car01.jpg -font Helvetica-Bold -pointsize 50 -draw \"gravity center fill black text 1,12 'SOLD' fill red text 0,11 'SOLD' \" sold.jpg");
And it doesn't go through. My error log has this:

Code: Select all

convert: unable to open image `sold.jpg':  @ error/blob.c/OpenBlob/2584.
[Mon Dec 06 17:39:52 2010] [error] [client 192.168.1.200] File does not exist: /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/sold.jpg, referer: http://kolamotors2/vehicles.php
[Mon Dec 06 17:39:52 2010] [error] [client 192.168.1.200] File does not exist: /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/sold.jpg, referer: http://kolamotors2/vehicles.php
[Mon Dec 06 17:39:54 2010] [error] [client 192.168.1.200] File does not exist: /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/sold.jpg, referer: http://kolamotors2/vehicles.php
[Mon Dec 06 17:39:54 2010] [error] [client 192.168.1.200] File does not exist: /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/sold.jpg, referer: http://kolamotors2/vehicles.php
The only difference I can see is that I'm escaping quotations. Is there a way to do this so it will work?

Re: Problem with escaping quotes PHP

Posted: 2010-12-06T17:01:32-07:00
by anthony
It isn't the command it is the environment.

PHP run from the web may not run in the same directory, or be able to write to the directory.

Re: Problem with escaping quotes PHP

Posted: 2010-12-07T07:22:31-07:00
by brianatlarge
Fixed it. Had to change this:

Code: Select all

    exec("/usr/local/bin/convert /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/car01.jpg -font Helvetica-Bold -pointsize 50 -draw \"gravity center fill black text 1,12 'SOLD' fill red text 0,11 'SOLD' \" sold.jpg");
To this:

Code: Select all

    exec("/usr/local/bin/convert /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/car01.jpg -font Helvetica-Bold -pointsize 50 -draw \"gravity center fill black text 1,12 'SOLD' fill red text 0,11 'SOLD' \" /home/brian/Kola_Motors/html/images/gallery/2006AudiA6-069767/thumb/sold.jpg");