Current location: Hot Scripts Forums » Programming Languages » PHP » Unable to retrive PHP variable within URL


Unable to retrive PHP variable within URL

Reply
  #1 (permalink)  
Old 05-11-09, 08:17 AM
i43haresh i43haresh is offline
New Member
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Unable to retrive PHP variable within URL

PHP Code:

<?
    $dbcnx 
= @mysql_connect('localhost''Haresh''REMOVED');
    
mysql_select_db('iwddb',$dbcnx);
    
$memberidresult = @mysql_query('SELECT * FROM members');
    
while (
$memberarray mysql_fetch_array($memberidresult))
    {
        
$memberid $memberarray['memberid'];
        echo 
'<br>The member id is'; echo $memberid;
        
$namelink $memberarray['name'];
        echo 
'<br>The name link via DB is '; echo $namelink;
        
// value of $namelink in database =    <a href="http://www.xyz.com/x/?x=c&amp;z=s&amp;v=1801659&amp;k=' . $memberid . '" target="_blank">Name Link</a>
        // ERROR: $memberid value is not getting passed within $namelink
    
}
?>

Last edited by Nico; 05-11-09 at 08:19 AM. Reason: Wrappers, mayne.
Reply With Quote
  #2 (permalink)  
Old 05-11-09, 08:32 AM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
Yeah, you can't do that. The string that comes from the db won't convert the variable in the string to an actual variable after you've pulled it out.

You can rebuild $namelink if it's the same for everyone though...

PHP Code:

$memberid $memberarray['memberid'];

$namelink '<a href="http://www.xyz.com/x/?x=c&amp;z=s&amp;v=1801659&amp;k='.$memberid.'" target="_blank">Name Link</a>'
Reply With Quote
  #3 (permalink)  
Old 05-11-09, 08:57 AM
i43haresh i43haresh is offline
New Member
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
How to i rebuild this?
If i enter in database only till = <a href="http://www.xyz.com/x/?x=c&amp;z=s&amp;v=1801659&amp;k=

no string shows in echo and hence i cant join 2 strings...


Can you pls help rebuilding this with a sample... your support will be highly appreciated. Thanks in advance.
Reply With Quote
  #4 (permalink)  
Old 05-11-09, 09:20 AM
i43haresh i43haresh is offline
New Member
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Hi,

I managed to rebuild it :

// value of $namelink in database = <a href="http://www.xyz.com/x/?x=c&amp;z=s&amp;v=1801659&amp;k=
//removed - ' . $memberid . '" target="_blank">Name Link</a>


echo $namelink;echo $memberid;echo '" target="_blank">Name Link</a>';
This works fine now. Thanks.


Just incase you have an easier / better way, pls share. Thanks a ton.
Reply With Quote
Reply

Bookmarks

Tags
php variable in url, url variable, variable within url


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show something depending on url variable bassyard JavaScript 7 10-19-07 02:17 PM
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 10:33 AM
PHP Variable Question kpowers4 PHP 7 03-28-06 02:52 AM
php variable help asrproductions PHP 5 02-11-06 05:50 PM
URL Rederecting with PHP? Cyder PHP 1 08-15-05 09:24 AM


All times are GMT -5. The time now is 08:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.