0

I'm using the following code but it gives me an error about an unexpeted " in the statement at this line, but I'm not sure how the syntax should go:

list($width,$height,$type,$attr) = getimagesize("' . $SESSION_["html_folder"] . '/uploadedfiles/' . $row['logo'] . '");

echo "<p>This logo is ".$width; x $.height; echo "pixels in size.</p>";

PHP says the error is on that first line.

2
  • 1
    The syntax highlighting here should show you what the problem is. You are opening a string with " but not closing it, needlessly as far as I can see. Commented Apr 6, 2011 at 14:58
  • its storing html_folder in your sessions is what im worried about Commented Apr 6, 2011 at 15:02

3 Answers 3

2

Try this

list($width,$height,$type,$attr) = getimagesize($SESSION_['html_folder'] . '/uploadedfiles/' . $row['logo']);

The error in your code was that you opened the string "twice", one with " and one with '. If you use a variable as parameter where a string is expected, you do not need to set the variable in quotes.

You should make sure that in $SESSION_['html_folder'] there's no malicious code, e.g. with

if(!is_dir($SESSION_['html_folder']))
   die("ERROR");
Sign up to request clarification or add additional context in comments.

4 Comments

nitpick: the code is not executable, single quotes are such a tiny reduction in performance, and it will also not read escape characters
@RobertPitt: the performance aim is not that big, I agree :-) But nevertheless I thought it is worth to say
No, it doesn't worth. There is no gain at all but only rumor. Call it your favorite coding style.
@Col. Shrapel: thanks for editing my post, I just wanted to remove the unworth words ^^
0

youre adding all kinds of unnecessary quotes

list($width,$height,$type,$attr) = getimagesize($SESSION_["html_folder"] . '/uploadedfiles/' . $row['logo']);

Comments

0

You want:

list($width,$height,$type,$attr) = getimagesize($_SESSION["html_folder"] . '/uploadedfiles/' . $row['logo']);

The main issue was that you were using double quotes to open a string, but you didn't close the string with double quotes. The above is a better formated string(and fixed your $_SESSION variable).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.