Jump to content

PLEASE HELLLP! Parse error: syntax error, unexpected T_STRING


Recommended Posts

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

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.

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

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.