0

In console I get this error in this paragraph, I've been trying for hours to see what's wrong and I can't find it.

    print ("<img id=".$fila["id"]." class=\"imageeenprueeba imagenusuario\" src=".$fila["nombrearchivo"]." alt=".$fila["descripcion"]." width=\"30\" height=\"30\" onclick=\"openImg(".$fila["id"].",\"".$fila["propietario"]."\")\">");
    
   

Any help would be appreciated

  • 2
    Since you're using `"` as the delimiter around the `onclick` attribute value, you can't use that as the delimiter around the function arguments as well. – Barmar Jan 21 '22 at 17:31
  • Use single quotes around `$filea["proprietario"]` instead of double quotes. – Barmar Jan 21 '22 at 17:32
  • 2
    Inline event handlers like `onclick` are [not recommended](/q/11737873/4642212). They are an [obsolete, hard-to-maintain and unintuitive](/a/43459991/4642212) way of registering events. Always [use `addEventListener`](//developer.mozilla.org/docs/Learn/JavaScript/Building_blocks/Events#inline_event_handlers_%E2%80%94_dont_use_these) instead. You’re making your life unnecessarily hard with trying to escape these quotes. – Sebastian Simon Jan 21 '22 at 17:38

1 Answers1

0

Thank you very much for your help! It's working now! This is the correct code:

print ("<img id=".$fila["id"]." class="imageeenprueeba imagenusuario" src=".$fila["nombrearchivo"]." alt=".$fila["descripcion"]." width="30" height="30" onclick="openImg(".$fila["id"].",'".$fila["propietario"]."')">");

Thank you and best regards