Skip to main content
Inspiring
November 3, 2006
Question

php print question

  • November 3, 2006
  • 11 replies
  • 391 views
Hi all............

I'm using the code below to populate a field in my enquiry form.
The problem is that some of the product names have characters such as & and
+ in the names and these are not showing.
So for instance, if a product has the name of "D+144 with 1&2 phase" the
product name would show as "D144 with 1"

Any ideas how i can get round this problem???

Thanks
Andy


<?php $_GET["product"]; ?>

<?php print $product; ?>


This topic has been closed for replies.

11 replies

Inspiring
November 6, 2006
Actinic simply display the &. in the product name if i use this.
No problem, i will change the ofending characters.

Cheers
Andy



"David Powers" <david@example.com> wrote in message
news:ein819$p1e$2@forums.macromedia.com...
> Andy wrote:
>> Thanks again Dave
>> I'm still not getting anything past the & :-(
>>
>> Think i'll have to replace all of the '&' with 'and' in my product names.
>
> An alternative is to replace & with &.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
November 6, 2006
Andy wrote:
> Thanks again Dave
> I'm still not getting anything past the & :-(
>
> Think i'll have to replace all of the '&' with 'and' in my product names.

An alternative is to replace & with &.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
November 6, 2006
Thanks again Dave
I'm still not getting anything past the & :-(

Think i'll have to replace all of the '&' with 'and' in my product names.

Andy


"David Powers" <david@example.com> wrote in message
news:ein2sk$jgd$1@forums.macromedia.com...
> Andy wrote:
>> Thanks Dave
>> I'm not sure how to actually use the urlencode within my link.
>> Please see the link below: to see what i have donw with it. This simply
>> gives the result as
>> urlencode(LEM Heme LH 1020 (Clamp 70mm 100A))
>>
>> <a href="javascript:;"
>> onclick="MM_openBrWindow('bestprice.php?product=urlencode(<actinic:variable
>> name="ProductName" />)','','width=500,height=350')"><img
>> src="best_price_enquiry.gif" width="177" height="19" border="0" /></a>
>
> urlencode() is a PHP function, so it needs to be in a PHP code block.
> However, the problem is that you're using Actinic. I have no idea how it
> works, but I doubt if you can use it in the middle of a PHP block. It
> might work if you use JavaScript. Try this:
>
> <a href="javascript:;"
> onclick="MM_openBrWindow(encodeURI('bestprice.php?product=<actinic:variable
> name="ProductName" />'),'','width=500,height=350')"><img
> src="best_price_enquiry.gif" width="177" height="19" border="0" /></a>
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
November 6, 2006
Andy wrote:
> Thanks Dave
> I'm not sure how to actually use the urlencode within my link.
> Please see the link below: to see what i have donw with it. This simply
> gives the result as
> urlencode(LEM Heme LH 1020 (Clamp 70mm 100A))
>
> <a href="javascript:;"
> onclick="MM_openBrWindow('bestprice.php?product=urlencode(<actinic:variable
> name="ProductName" />)','','width=500,height=350')"><img
> src="best_price_enquiry.gif" width="177" height="19" border="0" /></a>

urlencode() is a PHP function, so it needs to be in a PHP code block.
However, the problem is that you're using Actinic. I have no idea how it
works, but I doubt if you can use it in the middle of a PHP block. It
might work if you use JavaScript. Try this:

<a href="javascript:;"
onclick="MM_openBrWindow(encodeURI('bestprice.php?product=<actinic:variable
name="ProductName" />'),'','width=500,height=350')"><img
src="best_price_enquiry.gif" width="177" height="19" border="0" /></a>

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
November 6, 2006
Thanks Dave
I'm not sure how to actually use the urlencode within my link.
Please see the link below: to see what i have donw with it. This simply
gives the result as
urlencode(LEM Heme LH 1020 (Clamp 70mm 100A))

<a href="javascript:;"
onclick="MM_openBrWindow('bestprice.php?product=urlencode(<actinic:variable
name="ProductName" />)','','width=500,height=350')"><img
src="best_price_enquiry.gif" width="177" height="19" border="0" /></a>

I'll keep on experimenting with it.

Andy






"David Powers" <david@example.com> wrote in message
news:eiftbt$afn$2@forums.macromedia.com...
> Andy wrote:
>> Ah right!
>> Well im using the Actinic Catalog software - Within the Actinic code
>> their is a variable that displays the product name. I am using this
>> variable in the href to the form. This then populates the form field
>> 'product name'
>
> Right. It's that variable that needs to be passed to urlencode() when
> adding it to the query string at the end of the link.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
November 3, 2006
Andy wrote:
> Ah right!
> Well im using the Actinic Catalog software - Within the Actinic code their
> is a variable that displays the product name. I am using this variable in
> the href to the form. This then populates the form field 'product name'

Right. It's that variable that needs to be passed to urlencode() when
adding it to the query string at the end of the link.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
November 3, 2006
Ah right!
Well im using the Actinic Catalog software - Within the Actinic code their
is a variable that displays the product name. I am using this variable in
the href to the form. This then populates the form field 'product name'

I will take another look at it on Monday - Thanks Again

Have a good weekend!

Andy


"David Powers" <david@example.com> wrote in message
news:eifrl8$88t$2@forums.macromedia.com...
> Andy wrote:
>> I've changed it to <?php print urlencode ($product); ?> is this
>> correct?
>
> No. It's where the $_GET value is coming from in the first place that's
> the problem. Without knowing more about where you're getting the product
> names from (a database, maybe?), it's impossible to say what you need to
> do.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
November 3, 2006
Andy wrote:
> I've changed it to <?php print urlencode ($product); ?> is this correct?

No. It's where the $_GET value is coming from in the first place that's
the problem. Without knowing more about where you're getting the product
names from (a database, maybe?), it's impossible to say what you need to do.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
November 3, 2006
Hi Dave
Thanks for replying.

I've changed it to <?php print urlencode ($product); ?> is this correct?
I'm still not getting the '&' and with other products im getting the + and %
between words.

Thanks
Andy


"David Powers" <david@example.com> wrote in message
news:eifpvt$6kc$1@forums.macromedia.com...
> Andy wrote:
>> I'm using the code below to populate a field in my enquiry form.
>> The problem is that some of the product names have characters such as &
>> and + in the names and these are not showing.
>> So for instance, if a product has the name of "D+144 with 1&2 phase" the
>> product name would show as "D144 with 1"
>
> It's got nothing to do with PHP, but with the way that you are passing
> values through the query string. Anything passed through a query string
> needs to be URL encoded. Forms should do this automatically, but if you're
> getting the information from elsewhere, you need to pass it to urlencode()
> before sending it through the get method.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
November 3, 2006
I'm not sure, but I think addslashes will help you?


"Andy" <me@work.com> wrote in message
news:eifpaj$5rk$1@forums.macromedia.com...
> Hi all............
>
> I'm using the code below to populate a field in my enquiry form.
> The problem is that some of the product names have characters such as &
> and + in the names and these are not showing.
> So for instance, if a product has the name of "D+144 with 1&2 phase" the
> product name would show as "D144 with 1"
>
> Any ideas how i can get round this problem???
>
> Thanks
> Andy
>
>
> <?php $_GET["product"]; ?>
>
> <?php print $product; ?>
>