PHP onmouseover更改从数据库调用的图像

  echo'<img src="'.$row['filename'].'" onmouseover="this.src='.$row['back_filename'].'" onmouseout="this.src='.$row['filename'].'" />';

I'm calling in 2 images from a database using mySql and php, How come this onmousover doesn't work? ps. I'm calling a path to the image not storing the image in the database itself.

try this

echo'<img src="'.$row['filename'].'" onmouseover="this.src=\''.$row['back_filename'].'\'" onmouseout="this.src=\''.$row['filename'].'\'" />';

You are not providing the needed quotes for the inline javascript, you need single quotes '' around the filename as it is a string, causing whatever the variables hold to be interpreted by javascript as something other than what you expect.

Also use a heredoc to help with preventing errors caused by misquoting and worrying about escaping quotes.

echo <<<END
   <img src="{$row['filename']}" onmouseover="this.src='{$row['back_filename']}'" onmouseout="this.src='{$row['filename']}'" />
END;