473,473 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

conflict for function copy() .

3 New Member
HI,

I am using the copy() function to download a web page as shown in this
example:
[php]
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$context_options = array (
'http' => array (
'method' => 'GET',
'header'=> "User-Agent: $userAgent"

)
);

$context = stream_context_create($context_options);
copy("http://www.example.com", "test/test.html", $context);[/php]

However, contrary to the PHP document for the copy() function:

bool copy ( string $source , string $dest [, resource $context ] )

it returns the following error:

Warning: Wrong parameter count for copy() in /var/www/printer/
test2.php on line 17

The copy() works fine except when the third parameter is included but,
in this case it returns http code 403 because the User-Agent isn't
specified. Is it possible to include the third parameter hence,
resource $context as stated in the documentation, is this a bug, or is
there something wrong with my code?

I am using Ubuntu/Linux 7.04 and php 5.2.1.

Thanks,

Carl

www. gaihosa. com

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Mar 23 '08 #1
2 2825
brokensilence
4 New Member
HI,

I am using the copy() function to download a web page as shown in this
example:
Expand|Select|Wrap|Line Numbers
  1. $userAgent = $_SERVER['HTTP_USER_AGENT'];
  2. $context_options = array (
  3.         'http' => array (
  4.             'method' => 'GET',
  5.             'header'=> "User-Agent: $userAgent"
  6.  
  7.             )
  8.         );
  9.  
  10. $context = stream_context_create($context_options);
  11. copy("http://www.example.com", "test/test.html", $context);
However, contrary to the PHP document for the copy() function:

bool copy ( string $source , string $dest [, resource $context ] )

it returns the following error:

Warning: Wrong parameter count for copy() in /var/www/printer/
test2.php on line 17

The copy() works fine except when the third parameter is included but,
in this case it returns http code 403 because the User-Agent isn't
specified. Is it possible to include the third parameter hence,
resource $context as stated in the documentation, is this a bug, or is
there something wrong with my code?

I am using Ubuntu/Linux 7.04 and php 5.2.1.

Thanks,

Carl
Perhaps trying this with your array structure (adding line returns to the header info)?

Expand|Select|Wrap|Line Numbers
  1. $context_options = array (
  2.         'http' => array (
  3.             'method' => 'GET',
  4.             'header'=> "User-Agent: $userAgent \r\n"
  5.  
  6.             )
  7.         );
  8.  
  9.  
Mar 24 '08 #2
bandito40
3 New Member
Thanks for the reply. I actually over looked that. I should have noticed it on the php site. Sometimes you need another pair of eyes.

Carl


http://www.gaihosa.com

Perhaps trying this with your array structure (adding line returns to the header info)?

Expand|Select|Wrap|Line Numbers
  1. $context_options = array (
  2.         'http' => array (
  3.             'method' => 'GET',
  4.             'header'=> "User-Agent: $userAgent \r\n"
  5.  
  6.             )
  7.         );
  8.  
  9.  
Mar 24 '08 #3

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

Similar topics

7
by: Tim Gaunt | last post by:
Hi, I'm hoping that someone will be able to help me with this one, I'm developing an application which basically inserts a load of data into the database ready for validation at a later date, I...
6
by: Max | last post by:
Hi, I have SqlServer 2000 as back end and Access 2000 as front-end. All tables from Sqlserver are linked to Access 2000. I am having write conflict problem with one of my form which is bound to...
0
by: Zlatko | last post by:
There is a bound form for data input in Access Project (Access front-end with SQL Server), which is based on a strored procedure (in-line function) that queries several joined tables. It is...
16
by: Vadim Biktashev | last post by:
Hello all I would like to give a certain name to a certain global variable. Unfortunately, this name is already used in math.h for a mathematical function. Worse, I do need to use maths library...
0
by: vb | last post by:
Hi, Sorry, I am new to C#, so this can be a very simple question. I am using some of DevExpress components in my application.My References in the Solution(for DevExpress) are: DevExpress.Data;...
5
by: quortex | last post by:
Hi all, I have a class which contains a method called GetMessage(). When I compile and unit test it all is well. However in the application I want to use it in there appears to be a conflict...
11
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). I have been running the following query with good results. The query lets me enter the month period and returns the SUM of the age fields. SELECT ...
14
lotus18
by: lotus18 | last post by:
Hello World I have a problem in detecting the conflict schedule (Day and Time). Day 1. M 2. T 3. W 4. TH 5. F
14
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.