Problem with Curl password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
michaelh613
Forum Commoner
Posts: 38
Joined: Sun Mar 16, 2008 1:35 pm

Problem with Curl password

Post by michaelh613 »

The error I receive is

Parse error*: syntax error, unexpected ':' in xxx\xxx\xx on line *120*

line 120 is

Code: Select all

curl_setopt($ch, CURLOPT_USERPWD, $this->$user:$this->$password);
I have also tried this hard coding in the uid and password and verified I receive the same error.

Documentation seems to support this usage

It appears to be correct

curl::option CurlHandle,"USERPWD","verhas:m23kkdUT"

Pass a string as parameter, which should be username:password to use for the connection. If the password is left out, you will be prompted for it.

http://www.scriptbasic.com/html/texi/mo ... _3.23.html

Any help will be appreciated.
scriptah
Forum Commoner
Posts: 27
Joined: Sat Mar 15, 2008 8:58 pm
Location: Long Island, NY

Re: Problem with Curl password

Post by scriptah »

Hello,

Code: Select all

 
curl_setopt($ch, CURLOPT_USERPWD, $this->$user:$this->$password );
 
You didn't wrap the red section with quotes, so the interpreter is interpreting them literally and not as a string.

Which means, it's interpreting the operator ':' (Paamaym Nekudotaim ).
You should do:

Code: Select all

 
curl_setopt($ch, CURLOPT_USERPWD, "{$this->$user}:{$this->$password}");
 
michaelh613
Forum Commoner
Posts: 38
Joined: Sun Mar 16, 2008 1:35 pm

Re: Problem with Curl password

Post by michaelh613 »

scriptah wrote:Hello,

Code: Select all

 
curl_setopt($ch, CURLOPT_USERPWD, $this->$user:$this->$password );
 
You didn't wrap the red section with quotes, so the interpreter is interpreting them literally and not as a string.

Which means, it's interpreting the operator ':' (Paamaym Nekudotaim ).
You should do:

Code: Select all

 
curl_setopt($ch, CURLOPT_USERPWD, "{$this->$user}:{$this->$password}");
 

Thanks
Post Reply