lukeh Posted March 14, 2007 Share Posted March 14, 2007 Hi, am going nuts over this - constantly getting "Parse error: syntax error, unexpected T_STRING. It is somewhere in the second line of this snippet (where $html_price is defined) if ($perm->check("admin,storeadmin,shopper")) { $html_price = "<a href="java script:void(0)"onclick="window.open\'http://www.holycow.com.au/SR/media/price/{product_sku}.html\', \'win2\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=600,height=150,directories=no,location=no/">View Price</a>/'; } else { $html_price = ""; } **btw in above code javascript has a space intentionally to get it thru forum firewall thingo** If anyone can see what i am doing wrong - please tell me! I have read the sticky on javascript & php but still cant see whats wrong! (rank newb) The code is supposed to verify permissions, then if user allowed to build a javascript link to be passed to another php template file, using the product sku from the database to create the url - is this the right way to do what I am trying to do? Cheers, Luke Quote Link to comment https://forums.phpfreaks.com/topic/42664-please-helllp-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
Orio Posted March 14, 2007 Share Posted March 14, 2007 You need to escape quotes within quotes... You also have errors in your js. Here's how it should be imo: $html_price = "<a href=\"java script:void(0)\" onclick=\"window.open('http://www.holycow.com.au/SR/media/price/{product_sku}.html\', \'win2\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=600,height=150,directories=no,location=no)\">View Price</a>"; Orio. Quote Link to comment https://forums.phpfreaks.com/topic/42664-please-helllp-parse-error-syntax-error-unexpected-t_string/#findComment-206991 Share on other sites More sharing options...
lukeh Posted March 14, 2007 Author Share Posted March 14, 2007 Hey Orio, thanks heaps for that! that code i pasted was really bad - i swear i closed the <a> tag! now the page works, and generates a link when i log in - i am stoked! the only problem - the link doesnt work... just a dead link, says javascript:void(0) in the status bar but that's it (and makes click sound!). the source from the page looks fine: <a href="java script:void(0)" onclick="window.open('http://www.holycow.com.au/SR/media/price/H02.html\', \'win2\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=600,height=150,directories=no,location=no)">View Price</a> btw the code is now $product_sku = $db_product->f("product_sku"); if ($perm->check("admin,storeadmin,shopper")) { $html_price = "<a href=\"java script:void(0)\" onclick=\"window.open('http://www.holycow.com.au/SR/media/price/$product_sku.html\', \'win2\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=600,height=150,directories=no,location=no)\">View Price</a>"; } else { $html_price = ""; } **and yes the space is still intentional! x2 have tested in both IE and Firefox, allowing popups but no luck... can you see anything? thanks again! luke Quote Link to comment https://forums.phpfreaks.com/topic/42664-please-helllp-parse-error-syntax-error-unexpected-t_string/#findComment-207061 Share on other sites More sharing options...
per1os Posted March 14, 2007 Share Posted March 14, 2007 My bad just saw that the space was intentional. Anyhow, I would remove the javascript:void0 from the href and put # and after the windo.open(); add return false; <a href="#" onclick="window.open('http://www.holycow.com.au/SR/media/price/H02.html\', \'win2\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=600,height=150,directories=no,location=no); return false;">View Price</a> --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42664-please-helllp-parse-error-syntax-error-unexpected-t_string/#findComment-207161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.