User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » need some help with curl-php Page [1]  
umbrellaman
All American
10892 Posts
user info
edit post

I'm trying to download jpegs from a website, and am using a php script to do it. I supply the urls correctly, but I keep on getting a "no url set!" error. I can see the images appear in the correct directories, but when I inspect them they contain no data and cannot be displayed. No matter what I do, the script keeps insisting that I haven't set any urls, even if I feed them in directly as raw strings. What am I doing wrong? Here is the essential code:

$fp = fopen($file_path,"w") or die("fuck!\n");
$ch = curl_init() or die("fuck again!\n");
curl_setopt($ch, curlopt_URL, $url);
curl_setopt($ch, curlopt_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);

One more thing. If I don't set curlopt_URL and instead put the url inside of curl_init(), I get a bunch of gibberish appear in my terminal. This does not happen when the code is run as shown. What does that mean?

8/6/2009 11:08:02 PM

FroshKiller
All American
51911 Posts
user info
edit post

Maybe a dumb question, but aren't the cURL option constants in all caps (e.g. CURLOPT_URL)?

8/6/2009 11:24:12 PM

umbrellaman
All American
10892 Posts
user info
edit post

I didn't think it would matter, but I can try that.

8/6/2009 11:31:28 PM

FroshKiller
All American
51911 Posts
user info
edit post

http://us.php.net/manual/en/language.constants.php

Quote :
"A constant is case-sensitive by default. By convention, constant identifiers are always uppercase."

8/6/2009 11:33:07 PM

umbrellaman
All American
10892 Posts
user info
edit post

FroshKiller pwns once again, capitalizing seems to have done the trick.

Thanks Frosh.

8/6/2009 11:38:06 PM

FroshKiller
All American
51911 Posts
user info
edit post

That is exactly the kind of thing I would've pulled my hair out over. I feel your pain.

8/6/2009 11:41:55 PM

evan
All American
27701 Posts
user info
edit post

lol

with any programming language, it's safer to assume that EVERYTHING is case-sensitive.

8/6/2009 11:47:36 PM

 Message Boards » Tech Talk » need some help with curl-php Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.