THis is probably a javascript syntax problem, but I can't pass my variable value in a link to a php script.
I'm trying to use javascript to display information looked up in a php script, as described in the tips
http://phpbuilder.com/tips/item.php?id=529
My html file contains:
<html>
blah, blah blah
<SCRIPT LANGUAGE="JavaScript" type="text/javascript" SRC="lookup.php?prodName=\'test product 1\'">
</SCRIPT>
</html>
in lookup.php:
<? php
some database stuff ...
$cartlink = '<a href=\'cart2.php?action=add_item&prodId='.$prodId.'&qty=1\'>Add to Shopping Cart</a><br>';
?>
<!--
document.write("<?php echo $cartlink; ?>");
//-->
//eof
If I put
$prodName='test product 1';
in the file lookup.php, if works fine. It passes the prodId back to the javascript and the link in file.htm works perfectly.
As written, it doesn't pass $prodName to lookup.php, so the db lookup fails, and $prodId=null.
What's the proper syntax to pass prodName to lookup.php?