Jump to content

SYNTAX error in defining variable


e1seix

Recommended Posts

Have a ton of pop-up javascript links in my page. To tidy up the code, I have decided to declare all links at top of the page to keep them together and simply use the variable within the "a" brackets. Let me show you:

 

<?
$brand_edit = 'javascript:void(0)"onclick="window.open('/admin/form.php?db=outlet&tbl=brands&auto_increment=<? echo $auto_increment; ?>&action=edtamp;step=1','none','width=750,height=250,menubar=no,status=no,resizable=no,location=no,toolbar=no,scrollbars=yes,left=50,top=50,titlebar=no')'; ?>

<span class="float" style="width: 100px;"><a href="<? echo $brand_edit; ?>"><? echo $auto_increment; ?></a></span>

 

However, something things to go wrong as I'm getting an "Parse error: syntax error, unexpected '=' in ... on line 12"

 

Where am I going wrong with my syntax?

Link to comment
https://forums.phpfreaks.com/topic/211519-syntax-error-in-defining-variable/
Share on other sites

your quotes are a mess.

 

<?
$brand_edit = "javascript:void(0)\" onclick=\"window.open('/admin/form.php?db=outlet&tbl=brands&auto_increment=$auto_increment;&action=edtamp;step=1','none','width=750,height=250,menubar=no,status=no,resizable=no,location=no,toolbar=no,scrollbars=yes,left=50,top=50,titlebar=no')\""; ?>

 

Try that.

 

If you're going to use short tags you might as well just do this:

<span class="float" style="width: 100px;"><a href="<?=$brand_edit?>>

 

Note that I left off the closing href quote because you are adding the onclick event in brand_edit you need to close it in the brand_edit string.

 

I think that should work.

 

well if this isn't in a loop i would just do:

 

<span class="float" style="width: 100px;"><a href="javascript:void(0);" onclick="window.open('/admin/form.php?db=outlet&tbl=brands&auto_increment=<?=$auto_increment?>;&action=edtamp;step=1','none','width=750,height=250,menubar=no,status=no,resizable=no,location=no,toolbar=no,scrollbars=yes,left=50,top=50,titlebar=no')"></a></span>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.