473,413 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How do I access my script from another site ?

290 100+
Hi,
I have my image generator on one website and I want to use
the script on my second website. This scripts tracks the image
downloads to a database so I want to keep the scripts on that server.

Now I don't want to directly refer to the script of the other site in the HTML, so I am trying to access it via an intermediate php page,
so I tried this:

On my second website:

Expand|Select|Wrap|Line Numbers
  1. echo "<img src=\"http://www.second_site.com/sys/image_gen.php?url_id=$Db_prod\" 
  2. width='300px' height='200px' 
  3. alt='Thumbnail for $title_sht'  border='2'>";
And then, still on second website, in the image_gen.php

I just have :

Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['url_cd'])){ 
  2.   $prod  = $_GET['url_cd'];
  3.     <img src=\"http://first_web_site.com/gen_the_image.php?id=$prod\">
  4.     }
  5. ?>
But this "image redirect" doesn't work

Probably because I am doubling up on the <img src> tags but I don't
know how to do this.

Any ideas on how to make it work ?
Jan 28 '10 #1
11 2338
Markus
6,050 Expert 4TB
Try

Expand|Select|Wrap|Line Numbers
  1. echo file_get_contents('http://firstsite');
  2.  
Jan 28 '10 #2
jeddiki
290 100+
That's pretty good, but can I pass the url_cd variable over
with that method ?

I need to pass the ?id=$prod so that the
correct image gets generated.

( the prod code is the url_cd so it is the
same as the ?url_id=$Db_prod

sorry for mixing up the names a bit ! )
Jan 28 '10 #3
kovik
1,044 Expert 1GB
Well, if you know that the other page outputs an <img> tag, then why are you wrapping it in an <img> tag? The tag is already made for you. Either only use that tag, or change the script to only output the "src" attribute.
Jan 28 '10 #4
Markus
6,050 Expert 4TB
file_get_contents('http://secondsite/?var=1&var2=2')

Edit: Would a header() redirect work?

Expand|Select|Wrap|Line Numbers
  1. header("Location: http://secondsite/?var=1&var2=2");
Jan 28 '10 #5
jeddiki
290 100+
Well, if you know that the other page outputs an <img> tag, then why are you wrapping it in an <img> tag? The tag is already made for you. Either only use that tag, or change the script to only output the "src" attribute.
Yes ... but How ?

I tried the following:

Expand|Select|Wrap|Line Numbers
  1. <img src=\"http://www.SECOND-SITE.com/sys/webthumb.php?prod_id=$Db_prod\" 
  2. width='300px' height='200px' alt='Thumbnail for $title_sht'>
AND

Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['prod_id'])){ 
  2.   $$Db_prod  = $_GET['prod_id'];
  3.     file_get_contents('http://www.FIRST-SITE.com/image-gen.php?id=$Db_prod');
  4.     }
ALSO

Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['prod_id'])){ 
  2.   $$Db_prod  = $_GET['prod_id'];
  3.     file_get_contents('http://www.FIRST-SITE.com/image-gen.php?id=$Db_prod', FILE_BINARY);
  4.     }
But none of them work :(

Any other suggestions ?



.
Jan 29 '10 #6
kovik
1,044 Expert 1GB
file_get_contents returns a string.. You have to echo it. Also, if you are going to inject a variable directly into a string, you need to use double-quotation marks ("), not single-quotation marks ('). Single quotation marks don't parse variables.
Jan 29 '10 #7
jeddiki
290 100+
Thanks for your input,

So I tried this:


Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['prod_id'])){ 
  2.    $$Db_prod  = $_GET['prod_id'];
  3.    echo "file_get_contents(\"http://www.FIRST-SITE.com/image-gen.php?id=$Db_prod\", FILE_BINARY)";
  4.     }
and this:

Expand|Select|Wrap|Line Numbers
  1. if(isset($_GET['prod_id'])){ 
  2.    $$Db_prod  = $_GET['prod_id'];
  3.    echo "file_get_contents(\"http://www.FIRST-SITE.com/image-gen.php?id=$Db_prod\")";
  4.     }
But unfortunately neither worked.
Jan 30 '10 #8
kovik
1,044 Expert 1GB
...

Expand|Select|Wrap|Line Numbers
  1. echo file_get_contents("http://www.FIRST-SITE.com/image-gen.php?id=$Db_prod");
Jan 30 '10 #9
jeddiki
290 100+
Ahh -
now that is more interesting !

OK - I got it to work - thanks
Jan 30 '10 #10
kovik
1,044 Expert 1GB
Change this line:
Expand|Select|Wrap|Line Numbers
  1. $$Db_prod  = $_GET['prod_id'];
To this:
Expand|Select|Wrap|Line Numbers
  1. $Db_prod = $_GET['prod_id'];
Even if it doesn't help, it's likely what you meant to do. Using 2 dollar signs is very different than 1.
Jan 30 '10 #11
realin
254 100+
That should work for you .

http://www.digimantra.com/technology...sing-curl-php/

You can pass the query string in the URL as well.

Thanks
Realin !
Jan 31 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michael T. Peterson | last post by:
Hi again, I need to be able update my web site with info from a remote web site. At this other web site, the info I require is updated every 30 minutes, 24 hours per day. Life would be cool if...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
11
by: trinitypete | last post by:
Hi all, I have a user control that uses control literal to build a heading with a link, and a div containing links below. As the link heading is hit, I want to change the style of the div,...
4
by: Martin | last post by:
Hi, I am getting an "Access Denied" error when attempting to browse asp.net pages. I have installed ASP.NET 1.1.4322 on a domain controller. The machine also has ASP.NET 1.0.3705 installed on...
10
by: vvenk | last post by:
Hello: When I tried to use an Access database, I get the following exception: Server Error in '/WebGrid' Application....
8
by: lightcap | last post by:
Server Windows 2003. Created one web site, everything works fine. Copied the content to another folder and created another web site pointing to the copied contecnt for test purposes. Configuration...
4
by: TrinityPete | last post by:
Hi all, We have a web application that uses web services for data access and retrieval. The web app and web services reside under IIS on the same server(WIN2003). The virtual directories have...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
16
by: Ben Sehara | last post by:
Is there any way I can limit the access to my website? I have a site "A" and I want to allow access to it only from site "B" login user. If someone try to access site "A" directory, I want it...
3
by: derfer | last post by:
I am trying to import a .inf file into access (the file comes from the output of some 3rd party software). I have managed to convert the file by opeing it in notepad and re-saving then a seperate...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.