Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-08-03 13:49:14
Point:500 Replies:7 POST_ID:828524USER_ID:11059
Topic:
PHP Scripting Language;Apache Web Server;Windows XP Operating System
I just start to use XAMPP server for Apache and PHP on WIndow XP, and simple php program is
working fine. But When I try to connect remote website such as www.yahoo.com to
collect the data. it complaint the curl function of curl_init is not defined such as $curl = curl_init();
in the following php code
Fatal error: Call to undefined function curl_init() in C:xampphtdocsxamppcurl.php on line..
SO I am wondering, whether we could NOT use curl function of php on WIndow XP but it only works
on Linux server. Is it Right, any alternavtive besides using file_get_contents() ?
And the final question:
I would like to seperate the function code into other file and include in the main program
I tried to add this include "c:/mydir/php/include/my_curl.php but php always complaint can NOT
find the file of my_curl, so finally I put the my_curl function into my main program OR
include "my_curl" and save my_curl.php ,this works if save my_curl.php into c:xampphtdocsxampp
since I get a lot php file from c:mydir/php/include , so I could not copy all to
C;xampphtdocsxammp, any suggestion so xammp/apache server can locate anywhere the php file is saved or located
Please advise for those two questions
Duncan
working fine. But When I try to connect remote website such as www.yahoo.com to
collect the data. it complaint the curl function of curl_init is not defined such as $curl = curl_init();
in the following php code
Fatal error: Call to undefined function curl_init() in C:xampphtdocsxamppcurl.php on line..
SO I am wondering, whether we could NOT use curl function of php on WIndow XP but it only works
on Linux server. Is it Right, any alternavtive besides using file_get_contents() ?
And the final question:
I would like to seperate the function code into other file and include in the main program
I tried to add this include "c:/mydir/php/include/my_curl.php but php always complaint can NOT
find the file of my_curl, so finally I put the my_curl function into my main program OR
include "my_curl" and save my_curl.php ,this works if save my_curl.php into c:xampphtdocsxampp
since I get a lot php file from c:mydir/php/include , so I could not copy all to
C;xampphtdocsxammp, any suggestion so xammp/apache server can locate anywhere the php file is saved or located
Please advise for those two questions
Duncan
<?php///include "c:/mydir/php/include/my_curl.php" ///Not working for this include///include "my_curl.php" ///This work if save my_curl.php into c:xampphtdocsxampp$url="http://www.yahoo.com"$str=my_curl($url,"" , 7, TRUE,2,"");function my_curl( $url, $get_array=array(), $timeout=3, $error_report=TRUE, $minsize=1,$fd){ // PREPARE THE ARGUMENT STRING IF NEEDED // $get_string = ''; // foreach ($get_array as $key => $val) // { // $get_string // = $get_string // . urlencode($key) // . '=' // . urlencode($val) // . '&'; // } // $get_string = rtrim($get_string, '&'); if (!empty($get_string)) $url .= '?' . $get_string; $curl = curl_init(); // HEADERS AND OPTIONS APPEAR TO BE A FIREFOX BROWSER REFERRED BY GOOGLE $header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // BROWSERS USUALLY LEAVE BLANK // SET THE CURL OPTIONS - SEE http://php.net/manual/en/function.curl-setopt.php curl_setopt( $curl, CURLOPT_URL, $url ); curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6' ); curl_setopt( $curl, CURLOPT_HTTPHEADER, $header ); curl_setopt( $curl, CURLOPT_REFERER, 'http://www.google.com' ); curl_setopt( $curl, CURLOPT_ENCODING, 'gzip,deflate' ); curl_setopt( $curl, CURLOPT_AUTOREFERER, TRUE );if ($minsize==1) { curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($curl, CURLOPT_RANGE,"0-250000");} elseif ($minsize==0) { //curl_setopt( $curl, CURLOPT_RETURNTRANSFER, False ); curl_setopt($curl, CURLOPT_FILE, $fd); } elseif ($minsize==2) { curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );//curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );//curl_setopt($curl, CURLOPT_BUFFERSIZE, 4096); }elseif ($minsize==3) { curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($curl, CURLOPT_RANGE,"100000-1100000");}elseif ($minsize==4) { curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($curl, CURLOPT_RANGE,$fd);}//curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );//curl_setopt($curl, CURLOPT_BUFFERSIZE, 4096);if ($minsize==1) { curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); curl_setopt($curl, CURLOPT_RANGE,"0-250000");} curl_setopt( $curl, CURLOPT_TIMEOUT, $timeout ); // RUN THE CURL REQUEST AND GET THE RESULTS $htm = curl_exec($curl);//echo "$htm"; // ON FAILURE HANDLE ERROR MESSAGE //global $track; // declaring global variable if ($htm === FALSE) { if ($error_report) { $err = curl_errno($curl); $inf = curl_getinfo($curl); // echo "FAILC: $url TIMEOUT=$timeout, CURL_ERRNOC=$err"; // echo "FAILC: $url"; // echo "memory usage_curl=".memory_get_usage(). ""; // 57960 // var_dump($inf); } curl_close($curl); return FALSE; } // ON SUCCESS RETURN XML / HTML STRING curl_close($curl); return $htm;}?> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:92:93:94:95:96:97:98:99:100:101:102:103:104:105:106:
Expert: Dave Baldwin replied at 2024-08-04 22:34:45
Glad you got it working.
Author: duncanb7 replied at 2024-08-04 22:31:07
I uncomment extentsion for curl
and unstall previous Aapche and re-install Xampp server and restart Apache, and include
include "D:mydirphpincludemy_curl.php and all is working fine
and C: shoud be D: drvier in my case
Duncan
and unstall previous Aapche and re-install Xampp server and restart Apache, and include
include "D:mydirphpincludemy_curl.php and all is working fine
and C: shoud be D: drvier in my case
Duncan
Assisted Solution
Expert: kshna replied at 2024-08-03 19:09:20
200 points EXCELLENT
I am sure the above comments mite have helped you with enabling the curl and for your 2nd queston ... replace / with in the include path and it should all work....
it should be like
it should be like
Expert: Dave Baldwin replied at 2024-08-03 15:41:39
Sorry I forgot the part where you have to restart the web server before that takes effect. Remove the ';' and restart the web server.
Author: duncanb7 replied at 2024-08-03 14:43:04
IN window php.ini, just find only one word of "curl" and I try to enabled it by taking out ";" and re-run
the my php prgram , but it still get fatal error which can not find curl_init()
So how do I source php.ini again if I make change on php.ini ?
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
extension=php_mbstring.dll
extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mssql.dll
;extension=php_mysql_mysqlnd.dll
extension=php_mysql.dll
;extension=php_mysqli_mysqlnd.dll
extension=php_mysqli.dll
the my php prgram , but it still get fatal error which can not find curl_init()
So how do I source php.ini again if I make change on php.ini ?
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
extension=php_mbstring.dll
extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mssql.dll
;extension=php_mysql_mysqlnd.dll
extension=php_mysql.dll
;extension=php_mysqli_mysqlnd.dll
extension=php_mysqli.dll
Author: duncanb7 replied at 2024-08-03 14:33:41
I read the php.ini at C:xamppphp, found there is no curl enabled, is it curl function not bulid-in in php with Xampp Package
for WIndow XP.
DO you think could I add the following code in php.ini by myself that copied from my Linux server's php.ini ?
Curl
CURL support => enabled
CURL infomration => libcurl/7.21./0 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
for WIndow XP.
DO you think could I add the following code in php.ini by myself that copied from my Linux server's php.ini ?
Curl
CURL support => enabled
CURL infomration => libcurl/7.21./0 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accepted Solution
Expert: Dave Baldwin replied at 2024-08-03 14:02:24
300 points EXCELLENT
curl is available on windows but it may not be enabled. It is enabled on my copy of XAMPP. I don't remember whether I did it myself or it came enabled. All you need to do is uncomment the line in 'php.ini' which is in c:xamppphp.