-4

I am getting an error during my execution of the code:

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\apache2triad\htdocs\imagedisplay.php on line 28

<?php

$dir= "C:\apache2triad\htdocs\phppgadmin\images\phpimages";

$file_display= array('jpg', 'jpeg', 'png', 'gif');

if(file_exists($dir)== false) 
{
  echo "directory x not found";
}
else
{
  $dir_content= scandir($dir);

  foreach($dir_content as $file)
  {
    $file_type = strtolower(end(explode('.', $file)));
     
    // echo "$file <br> ";

    if($file !=='.' && $file !=='..')
    {
      //echo "$file <br> ";   
      echo "<img src="', $dir, '/', $file, '" alt="', $file, '"/>";
    }      
  }   
}
?>
6
  • Where is line 28 here? Also a dot (.) is used to concatenate strings in PHP, not a comma... Commented May 20, 2012 at 14:13
  • 3
    @lix: echo accepts multiple comma-separated arguments Commented May 20, 2012 at 14:15
  • please indent and format your code properly next time. Commented May 20, 2012 at 14:15
  • 1
    As usual, an editor or IDE with syntax highlighting would help. Commented May 20, 2012 at 14:17
  • plss help me in correcting the code...i have tried to concatenate using dot(.) but it still doesn't work.. Commented May 20, 2012 at 14:45

1 Answer 1

3
echo "<img src="', $dir, '/', $file, '" alt="', $file, '"/>";
               ^^-- here

You've essentially got two different strings back-to-back here, making this line completely invalid.

Sign up to request clarification or add additional context in comments.

2 Comments

then what is to be done to make it work
Start by learning basic PHP syntax rules. We can tell you the solution, but then you learn nothing and continue to make the same error elsewhere.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.