|
I tried using your code suggestion but when user recieved verification email and clicked on verify link, it gives "HTTP ERROR 500".
Also error_log has following:
PHP Parse error: syntax error, unexpected 'global' (T_GLOBAL), expecting case (T_CASE) or default (T_DEFAULT) or '}'
|
|
|
|
|
HTTP status 500 is an internal server error. So you need to look at your server logs, and maybe even add some debug code to find out what is going wrong.
Is this your code or did someone else write it?
|
|
|
|
|
Actually this code was written by an outside person.
I will check this further.
|
|
|
|
|
Actually issue has been fixed after adding your code suggestion to another place in the same PHP file:
$tm=array($sendid,'____',C_SNAME);
$message=template($w[588],$tm);
sendmail(C_FROMM,$i['email'],$subject,$message,'text');
}
$sendid = '';
global $sendid;
printm($str.$sendid);
}
|
|
|
|
|
Udaya Arunakantha wrote: this code was written by an outside person. Then you have my sympathy. I have faced similar issues in the past and it is never easy.
|
|
|
|
|
You are correct Richard, it's bit hard but your code suggestion worked for another code line in the same PHP code, see my last reply.
|
|
|
|
|
Following code is working fine up to PHP 7.4 but with PHP 8.1 it makes an error_log:
PHP Warning: Undefined variable $conn
Please suggest me a solution for this issue.
The relevant code line is:
if(!$conn) $conn = mysqli_connect(C_HOST,C_USER,C_PASS,C_BASE) or die($w[113]);
Full code of the function is:
function all_online_users()
{
if(!$conn) $conn = mysqli_connect(C_HOST,C_USER,C_PASS,C_BASE) or die($w[113]);
$sec = 300;
if(isset($_SESSION['m']))
{
$user = is_numeric($_SESSION['m']) ? $_SESSION['m'] : 0;
$MyAccess = 0;
}
else
{
$user = 0;
$MyAccess = -1;
}
$ip = ($user == 0) ? ip2int(ip()) : 0;
mysqli_query($conn,"DELETE FROM ".C_MYSQL_ONLINE_USERS." WHERE (time < DATE_SUB(NOW(), INTERVAL ".$sec." SECOND) AND NOW() > ".$sec.") or time > NOW()");
$result = @mysqli_query($conn,"SELECT * FROM ".C_MYSQL_ONLINE_USERS);
$cnt=array();$adduser=1;$addguest=1;$users=0;
while($result && $i = mysqli_fetch_array($result))
{
$cnt[$i['usertype']] = (isset($cnt[$i['usertype']])) ? $cnt[$i['usertype']] + 1 : 1;
If(($MyAccess >= 0) && ($user == $i['user']))
{
$adduser=$addguest=0;
}
If(($MyAccess < 0) && ($ip == $i['ip']))
{
$adduser=$addguest=0;
}
}
if($adduser || $addguest)
{
mysqli_query($conn,"INSERT INTO ".C_MYSQL_ONLINE_USERS." VALUES (NOW(),".$user.",'".$MyAccess."','".$ip."')");
$cnt[$MyAccess] = (isset($cnt[$MyAccess])) ? $cnt[$MyAccess] + 1 : 1;
}
$k=0;while(isset($cnt[$k]))
{
$users = $cnt[$k] + $users;
$k++;
}
if(isset($cnt['-1'])) define('ONLINE_GUESTS',$cnt['-1']);
else define('ONLINE_GUESTS','0');
define('ONLINE_USERS',$users);
}
all_online_users();
|
|
|
|
|
|
|
I'm testing my old PHP code with PHP 8.1 (code is working fine with PHP 7.4).
Following line is not working on PHP 8.1
$total += count($row[0]);
I tried with strlen but it gives totally wrong result because this count is counting messages, size of inbox.
if (!defined("_COMMON_")) {echo "stop";exit;}
include_once($ld_engine_path."inc_connect.php");
$m_result = mysqli_query($conn,"select new_mails from ".$mysql_table_prefix."users where id=$is_regist") or die("database error<br>".mysqli_error($conn));
if (mysqli_num_rows($m_result))
list($new_board_messages) = mysqli_fetch_array($m_result, MYSQLI_NUM);
if (!isset($new_board_messages)) $new_board_messages = "0";
mysqli_free_result($m_result);
$m_result = mysqli_query($conn,"select concat(subject,body) from ".$mysql_table_prefix."board where user_id=$is_regist") or die("database error: cannot retrieve mail-messages<br>".mysqli_error($conn));
$total = 0;
while ($row = mysqli_fetch_array($m_result, MYSQLI_NUM))
$total += count($row[0]);
$percentage = round($total / $max_mailbox_size *100);
mysqli_free_result($m_result);
|
|
|
|
|
What does "not working" mean, what are you trying to count?
|
|
|
|
|
You haven't explained what "not working" means. The only notable difference documented in that function between v7 and v8 is:
Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface, 1 would be returned, unless value was null, in which case 0 would be returned.
So either you're now getting a TypeError where previously you were just counting the number of rows; you're now getting the sum of the string lengths, whereas previously you were counting the number of rows; or something else is happening, which you haven't explained.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are correct, previously it was counting number of rows, now it's counting string lenghths which is not the requirement.
Please suggest me a solution
|
|
|
|
|
Replace:
$total += count($row[0]); with:
$total += 1;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes it worked!!
Thank you!
|
|
|
|
|
I'm trying to migrate my PHP code which is working on PHP 7.4 to PHP 8.1.
With PHP 8.1, following
if($message_id == "") {
code is triggering for logged in users too.
Can somebody point out common errors in this code?
require_once("inc_common.php");
include($engine_path."users_get_list.php");
set_variable("message_id");
set_variable("send_to");
set_variable("send_to_id");
$send_to_id = intval($send_to_id);
if (!$exists) {
$error_text = "$w_no_user";
include($file_path."designes/".$design."/error_page.php");
exit;
}
$u_ids = array();
$u_names = array();
$tmp_body = "";
$tmp_subject = "";
$info_message = "";
if($message_id == "") {
if ($send_to!="") {
$user_to_search = $send_to;
include($ld_engine_path."users_search.php");
if (!count($u_ids)) $info_message = "".str_replace("~",""".htmlspecialchars($send_to).""",$w_search_no_found)."<br>";
}
if ($send_to_id!="") {
include("inc_user_class.php");
$ttt = $is_regist;
$is_regist = $send_to_id; #fake again :(
include($ld_engine_path."users_get_object.php");
$u_ids[] = $is_regist;
$is_regist = $ttt;
$u_names[] = $current_user->nickname;
}
}
else {
$board_operation = "reply";
$id = $message_id;
include($ld_engine_path."board_process_message.php");
$u_ids[] = $board_message["from_id"];
$u_names[] = $board_message["from"];
$tmp_body = str_replace("<br>","\n",$board_message["body"]);
$tmp_body = "\n\n_______ ".str_replace("~", $board_message["from"], $w_user_wrote)." ______\n$tmp_body";
$tmp_subject = str_replace("\"",""","Re: ".$board_message["subject"]);
}
include($file_path."designes/".$design."/board_send.php");
modified 30-Mar-23 1:04am.
|
|
|
|
|
The only place that variable is mentioned prior to the test is the set_variable("message_id"); line.
As far as I can see, that's not a built-in PHP function. So you need to check what that function is doing, and try to work out why its behaviour has changed in PHP 8.
We can't do that for you, since we can't see the function.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for the tip.
I will check it
|
|
|
|
|
The issue has been resolved after adding null by replacing ""
Old code:
if ($send_to_id!="") {
New code:
if ($send_to_id!=null) {
But will it do the same?
|
|
|
|
|
I'm trying to migrate my PHP code which is working on PHP 7.4 to PHP 8.1.
With PHP 8.1, following "if" code executes Javascript but with PHP 7.4 it didn’t execute Js part and it was the normal state.
If I use null instead of “” after the != will it fix this? and is it correct?
if ($error != "") echo "<script>alert('".str_replace("<br>","\\n",str_replace("\n","\\n",str_replace("\r","",str_replace("'","\'",$error_text))))."');</script>";
|
|
|
|
|
I have tried that code in version 7 and 8 and get the same results in both. You need to provide some more details.
|
|
|
|
|
My code is working on PHP 7.4 and now I'm testing it with PHP 8 and getting following error_log:
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in D:\localhost\htdocs\chat\dtc\engine\mysql\board_alerter.php:13
board_alerter.php is as given below:
<?php
if (!defined("_COMMON_")) {echo "stop";exit;}
include_once($ld_engine_path."inc_connect.php");
$m_result = mysqli_query($conn,"select new_mails from ".$mysql_table_prefix."users where id=$is_regist") or die("database error<br>".mysqli_error($conn));
if (mysqli_num_rows($m_result))
list($new_board_messages) = mysqli_fetch_array($m_result, MYSQLI_NUM);
if (!isset($new_board_messages)) $new_board_messages = "0";
mysqli_free_result($m_result);
$m_result = mysqli_query($conn,"select concat(subject,body) from ".$mysql_table_prefix."board where user_id=$is_regist") or die("database error: cannot retrieve mail-messages<br>".mysqli_error($conn));
$total = 0;
while ($row = mysqli_fetch_array($m_result, MYSQLI_NUM))
$total += count($row[0]);
$percentage = round($total / $max_mailbox_size *100);
mysqli_free_result($m_result);
?>
Please suggest me a fix
|
|
|
|
|
Replacing count($row[0]); with strlen($row[0]); should do it.
|
|
|
|
|
Yes it worked!!
Thank you!
|
|
|
|
|
I'm having a htaccess redirection issue which I am unable to find a solution by searching on the Internet and also I did several htaccess rewrite codes, but nothing helped me.
The URL has a part %3F
Please give me a correct solution to redirect following URL using htaccess:
https://www.example.com/folder/%3F
to
https://www.example.com/folder/
modified 11-Mar-23 1:49am.
|
|
|
|