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
Inputting variables into another variable
Old 10-30-2008, 07:16 AM Inputting variables into another variable
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hiya,
I know how to merge variables together
PHP Code:
$var 'http://www.'
$var2 'google.com'
$var3 $var $var2
But how to I inject the variables into a include URL
For example.

PHP Code:
<?
$id1 
300
$id2 
500
$dataURL 
'http://mysite.com/test.php?id='.$id1.'&id2='.$id2.''#<-- only has 1 apostrophy but wont show in post
echo ($dataURL);
?>
As far as I am aware all it's doing is including the page as
http://mysite.com/test.php?id=&id2=
instead of
http://mysite.com/test.php?id=300&id2=500
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 10-30-2008 at 07:19 AM..
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-30-2008, 08:14 AM Re: Inputting variables into another variable
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
hi there,

in your post you say you want to "inject the variables into an include URL".. by that I assume you are using the include function... which isn't in your example... but anyway if you are including a url you wont need to assign the url the variables, as long as they are available on the parent page then then included page will see them too ...

PHP Code:
$var "test";
include (
'this.php'); 
test.php can call $var and will see "test", you dont need to do anything more
[/php]
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Old 10-30-2008, 10:05 AM Re: Inputting variables into another variable
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Well, I do need to inject it into the fetched URL because its an external page.
It needs to point to specific id.

PHP Code:
<?
$id1 
300
$id2 
500
$dataURL 
'http://mysite.com/test.php?id='.$id1.'&id2='.$id2.''#<-- only has 1 apostrophy but wont show in post
$result file_get_contents($dataURL);
echo (
$result);
?>
I forgot to include $result = file_get_contents($result);
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 10-30-2008 at 10:08 AM..
lothop is offline
Reply With Quote
View Public Profile
 
Old 10-30-2008, 10:10 AM Re: Inputting variables into another variable
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
I see, I'm with you..

well that above code works fine for me... what version of PHP are you using?

Try ..

PHP Code:
$id1 300;
$id2 500;
$dataURL "http://mysite.com/test.php?id=$id1&id2=$id2"#<-- only has 1 apostrophy but wont show in post
echo ($dataURL); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Old 10-30-2008, 07:16 PM Re: Inputting variables into another variable
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Sorry, it was my stupid mistake...
I had a mistype in the URL and it was only displaying the default page....

Sorry for wasting your time
I used '.$id1.'&id2='.$id2.' as i find it alot easier to read within the code.

Thanks for your replies
Added to your talkupation thingy
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 10-31-2008, 03:26 AM Re: Inputting variables into another variable
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 932
Trades: 7
ok excellent
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Reply     « Reply to Inputting variables into another variable
 

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.27262 seconds with 12 queries