PHP - What Does This Type Of Array Means ?
hello friends
what does this type of array means ? $data[] = $row; Similar TutorialsIs there a way to find out what the array type is? Example: Code: [Select] $array1 = array('red', 'pizza', '14'); $array2 = array('color' => 'red', 'food' => 'pizza', 'age' => '14'); if(is_recursive($array1)){ return TRUE; } else if(is_multidimensional($array2){ return TRUE; } else { return FALSE; } Hi friends how does this types of array operate ? pls help, I am repeatedly facing this code but my brain can't hold, i am familiar with multi dimensional array but what are these ? $data[$row['id']] $options['data']=$row[0]; Can anyone let me know what I am doing wrong. I am sure it will (after the fact) be obvious, but I don't see it right now. Wish to remove all array elements which do not implement ValidatorCallbackInterface. Thanks <?php interface ValidatorCallbackInterface{} class ValidatorCallback implements ValidatorCallbackInterface{} function array_filter_recursive($input) { foreach ($input as &$value) { if (is_array($value)) { $value = array_filter_recursive($value); } } return array_filter($input, function($v) { return $v instanceOf ValidatorCallbackInterface; }); } function recursive_unset(&$array) { foreach ($array as $key => $value) { if (is_array($value)) { recursive_unset($value); if(empty($value)) { unset($array[$key]); } } elseif(!$value instanceOf ValidatorCallbackInterface) { unset($array[$key]); } } } $validatorCallback = new ValidatorCallback(); $rules=[ 'callbackId'=>"integer", 'info'=>[ 'arrayofobjects'=>[$validatorCallback], 'foo1'=>'bar1' ], 'foo2'=>'bar2', 'bla'=>[ 'a'=>'aa', 'b'=>'bb', ], 'singleobject'=>$validatorCallback ]; echo('original rules'.PHP_EOL); var_dump($rules); $desiredrules=[ 'info'=>[ 'arrayofobjects'=>[$validatorCallback] ], 'singleobject'=>$validatorCallback ]; echo('desired rules'.PHP_EOL); var_dump($desiredrules); echo('array_filter_recursive'.PHP_EOL); var_dump(array_filter_recursive($rules)); echo('recursive_unset'.PHP_EOL); recursive_unset($rules); var_dump($rules);
original rules array(5) { ["callbackId"]=> string(7) "integer" ["info"]=> array(2) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } ["foo1"]=> string(4) "bar1" } ["foo2"]=> string(4) "bar2" ["bla"]=> array(2) { ["a"]=> string(2) "aa" ["b"]=> string(2) "bb" } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } desired rules array(2) { ["info"]=> array(1) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } array_filter_recursive array(1) { ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } recursive_unset array(2) { ["info"]=> array(2) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } ["foo1"]=> string(4) "bar1" } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } }
<?php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if (session_status() == PHP_SESSION_NONE) { session_start(); } if(!isset($_SESSION['login'])) { echo ("<script>location.href='../clogin/'</script>"); die(); } if (isset($_POST['submit'])) { include_once('db.php'); //get post details from user $UserNumber = $_POST['uNumber']; $sql = "SELECT * FROM customer WHERE user_number=?"; $stmt = $connection->prepare($sql); $stmt->bind_param('i', $UserNumber); $stmt->execute(); $result = $stmt->get_result(); $count = $result->num_rows; if($count == 1) { while($row = $result->fetch_assoc()); { $db_Uno = $row['user_number']; if($userNumber !== $db_Uno) { echo'<script>swal.fire("FAILED!!", "<strong>No Customer with the user number you entered.</strong><hr><br/><i> Check well and try Again.</i>", "error");window.setTimeout(function(){ window.location.href = "home.php"; }, 2000);</script>'; exit(); } else { } }//while loop } //end of if rslt }// end submit for transfer post ?>
I have a Windows-style ini file that contains entries as such:
[Timers] Timer(1)=50 Timer(2)=30 Timer(3)=20 The entries represent an array of 3 different timers Apparently parse_ini_file can't deal with the () format. Is there any way to use this format ini file without having to change how arrays are designated? I have a dropdown list which have some elements. I want to get all the elements of the dropdown list into a variable of type array. Any Idea??? Not sure how to find what is causing my issue here, I'm running smarty which gives me this error if I switch PHP version to 7.4 (was on 7.3) : - Quote
ERRNO: 8 The line the error refers to is this : -
<p class="cart_del_info_box_text"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <span class="cart_del_info_box_message"><?php echo $_smarty_tpl->tpl_vars['cart']->value->mDelivery['cartdeliverymessage'];?>
How do I go about finding which file has the actual problem? Thanks for any pointers. CMS: PHP-Fusion version 9.03.110, PHP version: 7.4.16, MySQL Server Version: 5.7.33-log, DB Driver: PDO MySQL My own support people at PHP-Fusion main site have been unable to help me with this problem and I'm hoping for some new eyes and new input on this error. First of all my script works perfectly fine and outputs the result desired. I know that my script is not using PDO prepared statements and I am not prepared to modify it to do so because too much would have to be changed. And I'm not fluent on PDO. My script is an event calendar and can be seen at this url: https://windy.whisperwillow.net/grims_blog/index.php The error only occurs 3 times on 3 lines. <?php echo "<div class='col-sm-12'>\n"; include BASEDIR."grims_blog/include/cal_func_inc.php"; $day=date('d'); $endDate=date('t',mktime(0,0,0,$cMonth,$day,$cYear)); echo "<div><span class='hdspan2'><b>".$locale['gb_510']."</b></span></div><p>\n"; echo "<table class='tbl-responsive' width='67%' align='center' border='0' cellpadding='0' cellspacing='0'><tr>\n"; echo "<td align='center' colspan='3'><img style='max-width:100%;height:auto;' src='".BASEDIR."grims_blog/images/calhead/forest.jpg'></td>\n"; echo "</tr><tr height='30' bgcolor='#960000'>\n"; echo "<td align='left'> <a class='mcaldate' href='".FUSION_SELF."?month=$prev_month&year=$prev_year' title='Last Month'>".$locale['gb_511']."</a></td><td align='center'><span class='mnthhd'>".date("F Y",strtotime($cYear."-".$cMonth."-01"))."</span></td><td align='right'><a class='mcaldate' href='".FUSION_SELF."?month=$next_month&year=$next_year' title='Next Month'>".$locale['gb_512']."</a> </td>\n"; echo "</tr></table>\n"; echo "<table width='67%' align='center' border='0' cellpadding='0' cellspacing='0'><tr><td class='cal-blank'>\n"; echo "<table width='100%' align='center' border='0' cellpadding='0' cellspacing='0'><tr bgcolor='#005E00' height='35'>\n"; foreach ($short_days as $key=>$val) { echo "<th style='text-align:center' width='14%'><span style='font-size:12px; color:yellow;'><b>".$val."</b></span></th>\n"; } echo "</tr><tr>\n"; $s=date('w', mktime (0,0,0,$cMonth,1,$cYear)); for ($ds=1; $ds<=$s; $ds++) { echo "<td class='cal-blank' height='35' style='text-align:center;' valign='middle'></td>\n"; } for ($d=1; $d<=$endDate; $d++) { if (date('w',mktime (0,0,0,$cMonth,$d,$cYear)) == 0) { echo "<tr>\n"; } $result = dbquery("SELECT post_id, post_title, post_date FROM ".DB_GRIMS_BLOG_POST." WHERE active='1' AND MONTH(post_date) = '$cMonth' AND DAY(post_date) = '$d'"); $data = dbarray($result); $stuff1 = $data['post_id'] ? $data['post_id'] : ""; if ($stuff1) { $id = $stuff1; } else { $id = ""; } $stuff2 = $data['post_title'] ? $data['post_title'] : ""; if ($stuff2) { $title = $stuff2; } else { $title = ""; } $stuff3 = strtotime($data['post_date']) ? strtotime($data['post_date']) : ""; if ($stuff3) { $evday = $stuff3; } else { $evday = ""; } if (date("d", intval($evday)) == $d) { echo "<td height='35' class='event' align='center' valign='middle'>\n"; } elseif ($d == $day && $cMonth == date('m') && $cYear == date('Y')) { echo "<td height='35' class='today' align='center' valign='middle'>\n"; } else { echo "<td height='35' class='cal-norm' align='center' valign='middle'>\n"; } if ($d == $day && $cMonth == date('m') && $d <> $evday) { echo "<a class='cal2' href='".BASEDIR."grims_blog/filtered.php?post_id=$id' title='".$locale['gb_513']." $title'><b>$d</b></a>\n"; } elseif ($d == $day && $cMonth == date('m') && $d == $evday) { echo "<a class='cal2' href='#'><b>$d</b></a>\n"; } elseif ($evday) { echo "<a class='ecal' href='".BASEDIR."grims_blog/filtered.php?post_id=$id' title='$title'><b>$d</b></a>\n"; } else { echo "<span class='noevt'><b>$d</b></span>\n"; } echo "</td>\n"; if (date('w',mktime (0,0,0,$cMonth,$d,$cYear)) == 6) { echo "</tr>\n"; } } echo "</table></td></tr></table>\n"; echo "</td></tr></table><p></div>\n"; ?> Well I could not add comments to the posted script. These 3 lines of the db query area give the error in my error log: 1) $stuff1 = $data['post_id'] ? $data['post_id'] : ""; /* Trying to access array offset on value of type bool */ 2) $stuff2 = $data['post_title'] ? $data['post_title'] : ""; /* Trying to access array offset on value of type bool */ 3) $stuff3 = strtotime($data['post_date']) ? strtotime($data['post_date']) : ""; /* Trying to access array offset on value of type bool */ I know I am asking a lot for help on older code but would really appreciate it if someone can take a look. Edited April 19 by OldGrimClarify error lines Hi, WHAT: So I cannot for the life of me figure out why I'm getting this error. I'm trying to create a function that will display the user information from the database in a table but I have like a ton of these errors on the page and I don't know whats wrong. STEPS TO RESOLVE: So I've gone over my code a bunch of types to make sure that all the variables and what not were spelled correctly and as far as I can tell they are. I've also googled this issue to see if I can find a solution but none of them are very helpful. I honestly don't know whats wrong so kinda hard to find ways to resolve an issue, I don't even really know what this error means. THE CODE: This is where I put the function into action <?php display_table( array( "id" => "Id", "emailaddress" => "Email", "firstname" => "First Name", "lastname" => "Last Name", "salesperson" => "Salesperson", "phonenumber" => "Phone Number", "extension" => "Extension", "type" => "Type" ) ); ?> //This is the function <?php function display_table($fields, $data, $rows, $page){ if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $firstRecord = ($page - 1) * ROWS_PER_PAGE; $pageNumbers = ceil($rows / ROWS_PER_PAGE); echo '<div class="table-responsive w-75 mx-auto py-3"> <table class="table table-dark table-bordered table-sm"> <thead> <tr>'; foreach($fields as $key){ echo '<th class="py-2">' . $key . '</th>'; } echo '</tr> </thead> </tbody>'; $keys = array_keys($fields); for($record = $firstRecord; $record < $firstRecord + ROWS_PER_PAGE; $record++){ $row = $data[$record]; echo '<tr>'; for($recordCount = 0; $recordCount < count($keys); $recordCount++){ $column = $keys[$recordCount]; echo '<td class="py-2">' . $row[$column] . '</td>'; } echo '</tr>'; } echo '</tbody> </table'; for($pages = 1; $pages <= $pageNumbers; $pages++){ echo '<a class="btn btn-dark mx-1" href=?page=' . $pages . '</a>'; } } ?> Any help/advice would be really appreciated hi, very strange issue. when I create test e-mail or I will forward the specific e-mail, the script works correctly - saves attachment into server disk. now, when I configure to check another mailbox, it gives me error: Num Messages 11 Fatal error: Cannot use object of type stdClass as array in /test/emailattach/index.php on line 34 index.php: Code: [Select] <?php $mbox = imap_open("{mail.server.com:143}", "email@email", "XXX") or die('Cannot connect to mail: ' . imap_last_error()); // make connection with mailbox and check # messages if ($hdr = imap_check($mbox)) { echo "Num Messages " . $hdr->Nmsgs ."\n\n<br><br>"; $msgCount = $hdr->Nmsgs; } else { echo "failed"; } $overview=imap_fetch_overview($mbox,"1:$msgCount",0); $size=sizeof($overview); // get message info for($i=$size-1;$i>=0;$i--) { $val=$overview[$i]; $msg=$val->msgno; $from=$val->from; $date=$val->date; $subj=$val->subject; $seen=$val->seen; $from = ereg_replace("\"","",$from); // Check for attachements and store them $struct = imap_fetchstructure($mbox,$msg); $contentParts = count($struct->parts); if ($contentParts >= 2) { for ($ix=2;$ix<=$contentParts;$ix++) { $att[$ix-2] = imap_bodystruct($mbox,$msg,$ix); } for ($k=0;$k<sizeof($att);$k++) { if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") { if ($att[$k]->parameters[1]->value != "") { $FileName[$k] = $att[$k]->parameters[1]->value; $FileType[$k] = strrev(substr(strrev($FileName[$k]),0,4)); } } elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") { $FileName[$k] = $att[$k]->parameters[0]->value; $FileType[$k] = strrev(substr(strrev($FileName[$k]),0,4)); $fileContent = imap_fetchbody($mbox,$msg,$file+2); $fileContent = imap_base64($fileContent); $localfile = fopen("$FileName[$k]","w"); fputs($localfile,$fileContent); fclose($localfile); } } } } imap_close($mbox); ?> Could there be some encoding issue? with thanks, Margus It's not PHP, but if anyone could tell me what that means and how I can edit it I would be eternally grateful. <Directory /var/www/vhosts/webaddress.co.uk/httpdocs> RMode config RUidGid (username) psacln </Directory> Can you please tell me what each of these lines of code means?
$allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); $length = 20; $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"]; $thumbnail = $newfilename . "." . $extension; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail); $sql = "INSERT INTO videos ( filename ) VALUES( $thumbnail )"; mysql_query($sql); $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>'; $description = $description . " \n " . $newfilename; I came across usage of ^= in one the password hashing codes and am trying to find what this operator means in PHP. hi everyone
i keep seeing the following Comparison Operators:
<>i see it used in the following context: if ($connection <> 'SSL') { $connection = 'NONSSL'; }be grateful if somone would tell me what it means, i looked online but could not find the symbol thanks Hello friends, in my database table or even php files i always find within the text something like this i love people\n i love world\n i love anything and sometimes \r and something \n\r so what does it mean is it like <br> or what ? thanks What means this syntax line: $comments = (array) $comments thanks in advance Code: [Select] <?php class Point { public $x; public $y; } // Random values 0 - 1 function random_float ($min,$max) { return ($min+lcg_value()*(abs($max-$min))); } // Fuzzy C Means Algorithm function distributeOverMatrixU($num_of_clusters, $arr,$m) { global $MatrixCentroids; $num_of_data = sizeof($arr); $MatrixPointX = $arr; // Fill the $MatrixU table with random values from 0 to 1 for($j = 0; $j < $num_of_data; $j++) { $sum = 0; for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = random_float(0,1); $sum += $MatrixU[$j][$i]; } // Normalize Data for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = $MatrixU[$j][$i]/$sum; } } // repeat 200 for($a = 0; $a<200; $a++) { for($i = 0; $i < $num_of_clusters; $i++) { $tempAx = 0; $tempBx = 0; $tempAy = 0; $tempBy = 0; for($j = 0 ; $j < $num_of_data; $j++) { $tempAx = $tempAx + pow($MatrixU[$j][$i],$m); $tempBx += pow($MatrixU[$j][$i],$m) * $MatrixPointX[$j]->x; $tempAy = $tempAy + pow($MatrixU[$j][$i],$m); $tempBy += pow($MatrixU[$j][$i],$m) * $MatrixPointX[$j]->y; } $MatrixCentroids[$i] = new Point(); $MatrixCentroids[$i]->x = $tempBx / $tempAx; $MatrixCentroids[$i]->y = $tempBy / $tempAy; } // Cluster Centers for($j = 0 ; $j < $num_of_data; $j++) { $tempSum = 0; for($i = 0; $i < $num_of_clusters; $i++) { // Distance between 2 points $distance1 = pow(($MatrixPointX[$j]->x - $MatrixCentroids[$i]->x),2); $distance2 = pow(($MatrixPointX[$j]->y - $MatrixCentroids[$i]->y),2); $distance = $distance1 + $distance2; $distance = sqrt($distance); $MatrixU[$j][$i] = pow(1/$distance , 2/($m-1)); $tempSum += pow(1/$distance, 2/($m-1)); } for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = ($MatrixU[$j][$i]/$tempSum); } $sum = 0; for($i = 0; $i < $num_of_clusters; $i++) { $sum += $MatrixU[$j][$i]; } // Norm Data for($i = 0; $i < $num_of_clusters; $i++) { $MatrixU[$j][$i] = $MatrixU[$j][$i]/$sum; } } } //print_r($MatrixCentroids); return $MatrixU ; } // Connect to DB $my_num = $_GET["cluster_number"]; $fuzz = $_GET["fuzz"]; require('db_connection.php'); $resultx=mysql_query("SELECT * FROM xdata"); $result=mysql_query("SELECT * FROM ydata"); // &#916;&#953;&#945;&#946;&#940;&#950;&#959;&#965;&#956;&#949; &#972;&#955;&#945; &#964;&#945; &#948;&#949;&#948;&#959;&#956;&#941;&#957;&#945; while ($a_row = mysql_fetch_array($result)) { for($j = 1 ; $j < 17; $j++) { $tmp_data[$j] = $a_row[ay.$j]; } } while ($x_row = mysql_fetch_array($resultx)) { for($j = 1; $j <17; $j++) { $p = new Point(); $p->x = $x_row[ax.$j]; $p->y = $tmp_data[$j]; $arr[] = $p; } } // Execute algorithm $data_in_clusters = distributeOverMatrixU($my_num, $arr,$fuzz); $size = sizeof($arr); $result=@mysql_query('select * from cluster0 limit 1', $link); if ($result) { echo "O &#960;&#943;&#957;&#945;&#954;&#945;&#962; &#965;&#960;&#940;&#961;&#967;&#949;&#953; &#954;&#945;&#953; &#960;&#961;&#941;&#960;&#949;&#953; &#957;&#945; &#948;&#953;&#945;&#947;&#961;&#945;&#966;&#959;&#973;&#957; &#959;&#953; &#960;&#961;&#959;&#951;&#947;&#959;&#973;&#956;&#949;&#957;&#949;&#962; &#949;&#947;&#947;&#961;&#945;&#966;&#941;&#962;...<BR>"; echo "&#916;&#953;&#945;&#947;&#961;&#945;&#966;&#942;...<BR>"; for($i = 0; $i <100; $i++) { $query="DROP TABLE cluster$i"; mysql_query($query,$link); } echo "H &#948;&#953;&#945;&#947;&#961;&#945;&#966;&#942; &#941;&#947;&#953;&#957;&#949; &#956;&#949; &#949;&#960;&#953;&#964;&#965;&#967;&#943;&#945;..."; } for($j = 0; $j < $my_num; $j++) { $query_c = "CREATE TABLE cluster$j(data_points_x FLOAT NOT NULL,data_points_y FLOAT NOT NULL)"; mysql_query($query_c,$link); } for($i = 0; $i < $size ; $i++) { $max = 0; $pos = 0; for($j = 0; $j < $my_num; $j++) { $tmp_point = $data_in_clusters[$i][$j]; if($tmp_point > $max) { $max = $tmp_point; $pos = $j; } } $xxxx = $arr[$i]->x; $yyyy = $arr[$i]->y; $query="INSERT INTO cluster$pos(data_points_x,data_points_y) values('$xxxx','$yyyy')";; mysql_query($query,$link); } echo "<br>"; echo "<img src='db_scatter.php' border=0 align=center width =600 height=400>"; // &#917;&#956;&#966;&#940;&#957;&#953;&#963;&#951; &#928;&#943;&#957;&#945;&#954;&#945; &#956;&#949; &#964;&#945; &#945;&#960;&#959;&#964;&#949;&#955;&#941;&#963;&#956;&#945;&#964;&#945; echo "<table width='500' border='2'>"; echo "<TR><TD><B>Points</B><BR></TD>"; for($i = 0; $i < $my_num; $i++){ $xxx = $MatrixCentroids[$i]->x; $yyy = $MatrixCentroids[$i]->y; echo "<TD>Cluster $i Centoid:<br><b>X:$xxx Y:$yyy</b></TD>"; } echo "</tr>"; for($i = 0; $i < $size ; $i++) { $x = $arr[$i]->x; $y = $arr[$i]->y; echo "<TR>"; echo "<TD><b>x:$x</b><br><b>y:$y</b></TD>"; for($j = 0; $j < $my_num; $j++) { $tmp_point = $data_in_clusters[$i][$j]; echo "<TD> $tmp_point</TD>"; } echo "</TR>"; } echo "</TABLE>"; ?> I am getting these errors . This is my complete HTML page. Everything seems to work fine but when i retweet a message these error show up. Here is my tweet.php and the errors are at line 32 and 41. Previously there was an error at line 24: It was like this: '.((!empty($tweet->retweetMsg) && $tweet->tweetID === $retweet['tweetID'] or $tweet->retweetID > 0) ? ' I changed it to this and the error went away '.((isset($retweet['retweetID']) ? $retweet['retweetID'] === $tweet->retweetID OR $tweet->retweetID > 0 : '') ? ' Maybe this could help! I will really appreciate any suggestion coming my way! hi there, i am fairly new to OOPs in php, i get an error when i declare the argument type (as object) in a function and pass the same type (object). class eBlast { public static function getEmail(object $result) { return $result->email; } } $r = mysql_fetch_object($query); eBlast::getEmail($r); echo gettype($r); // outputs: object error is : Code: [Select] Catchable fatal error: Argument 1 passed to eBlast::getEmail() must be an instance of object, instance of stdClass given, called in C:\wamp\www\integra\client\pl_eblast\admin\send_emails.php on line 145 and defined in C:\wamp\www\integra\client\pl_eblast\app\app.eBlast.php on line 8 if i remove the type declaration in the function it works, but just would like to know why it shows error when pass the same type, also isnt mysql_fetch_object is the instance of stdclass? thanks in advance! |