Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
can someone help me with this php command
Old 03-31-2010, 11:40 AM can someone help me with this php command
ZoC
Skilled Talker

Posts: 68
Trades: 0
command php:

PHP Code:
<?php
 $referer 
$_REQUEST['r']; // Referer ->
?>

<a href="category.php<? if ($r != "") { echo ""; } else { echo "?r=".$referer; } ?>"></a>

url1 example: http://www.domain.com/?r=google

if r=(google or another website) to show
<a href="category.php?r=google">Category</a>




url2 example: http://www.domain.com/?r=

if r=(nothing no website or text)
<a href="category.php">Category</a>
can someone help me with this litle command ... thanks

Last edited by chrishirst; 03-31-2010 at 12:04 PM..
ZoC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-31-2010, 02:47 PM Re: can someone help me with this php command
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
It seems like you were close, but you got your operator logic a little backwards (if $ir != "")

PHP Code:
<a href="category.php<?php echo (isset($_REQUEST['r']) AND !empty($_REQUEST['r'])) ? '?r=' urlencode($_REQUEST['r']) : ''?>">Category</a>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 03-31-2010 at 02:52 PM.. Reason: Forgot to add the parameter join (?)
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 05:24 AM Re: can someone help me with this php command
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
You'd be better off using empty() within your condition, and an isset() check when declaring $referer .. otherwise you'll generate a PHP notice if $_REQUEST['r'] isn't set...

PHP Code:
if (isset($_REQUEST['r']))
{
    
$referer urlencode($_REQUEST['r']);
}

// then..

if (!empty($referer)) echo '?r=' $referer
Edit: Sorry mgraphic didn't realise you'd included those in your example, thought you'd just corrected the logic. Though I don't think you realise empty() implicitly performs an isset() check when called, a combination of the two isn't necessary.

Last edited by adam89; 04-01-2010 at 06:47 AM..
adam89 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 06:32 AM Re: can someone help me with this php command
ZoC
Skilled Talker

Posts: 68
Trades: 0
works thank you mgraphic !

Last edited by ZoC; 04-01-2010 at 07:36 AM..
ZoC is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 07:38 AM Re: can someone help me with this php command
ZoC
Skilled Talker

Posts: 68
Trades: 0
adam89 i try your php code becouse was more easy yours but is not working ... this i did

<?php
if (isset($_REQUEST['r']))
{
$referer2 = urlencode($_REQUEST['r']);
}
if (!empty($referer2)) echo '?r=' . $referer2;
?>

and the url code:
<a href="ordernow.php<? echo $referer2; ?>"></a>

and is not working ...

if r=google is show me
<a href="ordernow.phpgoogle"></a>

can you please help me with this ... this command will help me a lot thanks
ZoC is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 07:41 AM Re: can someone help me with this php command
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
Change:

PHP Code:
<?php
 $referer 
$_REQUEST['r']; // Referer ->
?>

<a href="category.php<? if ($r != "") { echo ""; } else { echo "?r=".$referer; } ?>"></a>
To:

PHP Code:
<?php
if (isset($_REQUEST['r']))
{
    
$referer urlencode($_REQUEST['r']);
}
?>

<a href="category.php<?php if (!empty($referer)) echo '?r=' $referer?>"></a>
adam89 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 09:03 AM Re: can someone help me with this php command
ZoC
Skilled Talker

Posts: 68
Trades: 0
works ! thank you ! you save my day and my website
ZoC is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can someone help me with this php command
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18769 seconds with 12 queries