Hi,

I am working on a gallery feature for my website.

Currently I have the images displaying using a mysql query which returns the images and a product description for each image. I would like to add to the gallery by having a clickable link under each picture which will take me to a details.html page where more information is available about the product and it can be added to a shopping cart. At the moment when the image itself is clicked on, it displays a zoom image using lightbox, which is fine.

the bit of code I'm trying to add in:
[ echo "<a href= 'details.html?ProductID={$Row['ProductID']}'> details </a>";]

so this will have a clickable "details" under each picture which will take you to the details page for the product based on the ProductId.

I'm getting a parse error but I can't see why... I'd really appreciate any help,
Thanks

Dani AI

Generated

Brief follow-up and practical hardening notes after 's fix (which resolved the parse error caused by mixing string delimiters when emitting an HTML anchor from PHP).

Common causes and safer patterns

  • The parse error usually comes from nested quotes inside a PHP string. Build attributes without conflicting delimiters (concatenation, alternate delimiters, or simply exit PHP and write the small HTML block) to avoid that class of syntax errors.
  • Prefer small, readable output blocks instead of long, concatenated echo strings; it makes quoting problems and future edits far easier to spot.

Security and robustness checklist

  • Escape any value placed into HTML with htmlspecialchars to prevent XSS.
  • URL-encode values included in query strings with urlencode or rawurlencode.
  • On the details page, validate the incoming identifier (cast to integer if numeric) and use prepared statements (PDO or mysqli) for database access to avoid SQL injection. Handle missing or invalid IDs with a clear 404 or friendly error page.

Gallery / lightbox notes

  • If the gallery JavaScript binds anchors by selector (class or rel) to open images in a lightbox, ensure the product-detail link uses a different class/attribute so it does not trigger the lightbox.
  • If the details page needs server-side code, confirm the server executes PHP for that filename (rename to .php or enable PHP parsing for .html).

Debugging tips

  • Lint the file with php -l and enable error reporting on a development server to see parse errors and stack traces. Check server error logs if errors are not displayed.

These practices keep the simple link generation that provided both safe and maintainable for production.

Recommended Answers

All 3 Replies

echo "<a href= 'details.html?ProductID=".$Row['ProductID']."'> details </a>";

You are a superstar, thank you! :)

If this thread is solved,please press the link under the reply box :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.