I want to turn on or setup mbstring in my host, how can i do it ?
there is no way to alter the php configuration on free hosting
Itâs enabled already
Go to the control panel and click on âAlter PHP Configâ?
When I enter alter php, I see that only mbstring is in auto and there is no other option.
âUncaught TypeError: preg_match(): Argument #2 ($subject) must be of string type, given in CurlHandleâ they say that this problem may be caused by mbstring not being active ?
Can you share your websiteâs URL where this issue is displayed?
It seems to me that the second argument to the preg_match
function should be a string, but isnât. As to why that happens, itâs hard to tell.
Can you please provide more information? Things that would help include:
- The account username and/or domain on which you experience this issue.
- The full error message (what youâre sharing here appears to be cut off).
- The code where this error occurs (should be shown as part of the error message).
- Who says that that this may be mbstring related and where and how do they say this.
Maybe this is related to mbstring, maybe it isnât. But the information youâve shared so far doesnât have anything to do with mbstring, so I donât know.
metinsah.rf.gd the error is on index and also before I got this error this code was working fine here and even this code is running successfully on my âlocalhostâ
I see this error:
Fatal error : Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, CurlHandle given
Are you running PHP 7.4 on localhost? If so, perhaps your code was affected by a change in PHP 8, where curl handler resources were replaced with class objects:
What exactly are you trying to pass to the function? Can you share your code (removing any potentially sensitive parts)?
i am using php 5.6 on my localhost which version is php on localhost i dont now but I want to get specific html line with curl i think i will use the Php Curl Class on my script thank you for help If you have an idea I can try for this problem, I would like to try it. Thanks.
second one is not localhost ı mean this hosting php version.
Hi Bilocan,
preg_match has nothing to do with PHP versions whatsoever, itâs a regular expression function, and you might have accidentally passed in a CurlHandle into the function. Would you please share your code and we can see from there? Remember to hide all credentials or API keys if needed.
If you intend to have the response text to be matched, youâre looking for something like this:
$output = curl_exec($ch);
// some checking to see if it actually comes back 200 OK
preg_match('/(\d+)/', $output, $matches); // match all numbers, replace with your own regex.
print_r($matches);
Cheers!
Thank you for answer.
here is my code lines.
$ch_index = curl_init();
curl_setopt($ch_index, CURLOPT_URL, 'url');
curl_setopt($ch_index, CURLOPT_REFERER, 'url');
//curl_setopt($ch_index, CURLOPT_TIMEOUT, 10);
curl_setopt($ch_index, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch_index, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch_index, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch_index, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch_index, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch_index, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch_index, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch_index, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch_index, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch_index, CURLOPT_VERBOSE,true);
curl_setopt($ch_index, CURLINFO_HEADER_OUT, true);
curl_setopt($ch_index, CURLOPT_ENCODING , "gzip");
curl_setopt($ch_index, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.47");
$headers = [
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language: tr,en;q=0.9,en-GB;q=0.8,en-US;q=0.7',
'Content-Type: text/html; charset=UTF-8',
];
$curl_output = curl_close($ch_index);
// Veriyi parçalama iĆlemi
preg_match('@<div id="rank-player" (.*?)>(.*?)</div>@si',$ch_index,$parcel_player);
preg_match('@<div id="rank-guild" (.*?)>(.*?)</div>@si',$ch_index,$parcel_guild);
preg_match('@<div class="unique-times">(.*?)</div>@si',$ch_index,$parcel_time);
$parcel_player = $parcel_player[0];
$parcel_guild = $parcel_guild[0];
$parcel_time = $parcel_time[0];
?>
by the way this code was work this host about a yer ago and it still work on my localhost.
You donât seem to be executing the session anywhere in your code; I believe you should replace curl_close
with curl_exec
: PHP: curl_exec - Manual
curl_close
returns nothing: PHP: curl_close - Manual
I also think you mean to use preg_match
on $curl_output
, not on the $ch_index
which is automatically deleted when you call curl_close
according to the documentation. Iâm surprised this code is working for you in localhost.
This is how Iâm thinking it:
$curl_output = curl_exec($ch_index);
//Optionally
curl_close($ch_index);
// Veriyi parçalama iĆlemi
preg_match('@<div id="rank-player" (.*?)>(.*?)</div>@si',$curl_output,$parcel_player);
preg_match('@<div id="rank-guild" (.*?)>(.*?)</div>@si',$curl_output,$parcel_guild);
preg_match('@<div class="unique-times">(.*?)</div>@si',$curl_output,$parcel_time);
$parcel_player = $parcel_player[0];
$parcel_guild = $parcel_guild[0];
$parcel_time = $parcel_time[0];
Hahaha. Omg bro I feel stupid really.
Iâm still laughing at how I made this mistake
Thank your for all hepls.you did handle me
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.