-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...
    – Lix
    Commented May 20, 2012 at 14:13
  • 3
    @lix: echo accepts multiple comma-separated arguments
    – Marc B
    Commented May 20, 2012 at 14:15
  • please indent and format your code properly next time.
    – Femaref
    Commented May 20, 2012 at 14:15
  • 1
    As usual, an editor or IDE with syntax highlighting would help.
    – mario
    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..
    – ishu
    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.

2
  • then what is to be done to make it work
    – ishu
    Commented May 20, 2012 at 14:37
  • 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.
    – Marc B
    Commented May 20, 2012 at 20:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.