Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
enter image description here
show me how to fix this error , although there are quite a few posts but mine is a bit different . I don't understand php well thanks !
details of the error code line: $datainfo['category'] = $category['name'];
The error states that PHP cannot find the key "name" in an array. To counteract the error, you can make the following check and assignment at the point where the array is set.
Many ways to do it:
long version
if (! isset($category['name'])) {
$category['name'] = "";
}
medium long version
$datainfo['category'] = (isset($category['name'])) ? $category['name'] : "";
shortest version
$datainfo['category'] = $category['name'] ?? "";
For handle error, you can write code like:
$datainfo['category'] = (isset($category['name']))?$category['name']:"";
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm retrieving the postal code by using -
<?php $pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/'); ?>
It works great but if the postal code is not found, it says, "None". I can't find a way to disable the message.
You can empty the variable if the respond is None. With a simple check.
<?php
$pstcde = file_get_contents('https://ipapi.co/'.$_SERVER['REMOTE_ADDR'] . '/postal/');
if($pstcde === "None")
$pstcde = ""; //Empty string. Or you can use unset($pstcde); if you want to unset the variable.
?>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Kindly help correct the code below:
PHP Strict Standards: Only variables should be passed by reference in /home/xxxxxx/public_html/app/mods/Controller/Menu.php on line 15
The code is as below:
public function __call($function, $parameters){
$categoria = strtolower(str_replace('Action',NULL,$function));
$platillo = strtolower(array_pop( array_flip($_GET)));//line 15
Thank you in advance
array_pop requires a reference to a variable. A reference means it has to be a variable - i.e. you can do:
$x = ["a", "b"];
array_pop($x);
but not
array_pop(["a","b"]);
So, to fix your issue, you would do:
$flipped_get = array_flip($_GET);
$platillo = strtolower(array_pop($flipped_get));//line 15
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can i fix this? i want make this :
$diagnosa=blabla , blabla2 , blabla3 , ;
and then i use foreach but it cannot work,
$nama_diagnosa = Laporan::ViewDataDiagnosa(2,'2015-02-02');
$diagnosa = foreach ($nama_diagnosa as $cellDiagnosa){
echo $cellDiagnosa['nama_diagnosa']." , ";
}
[resolved]
Finally I added temporary variables to hold data for diagnosatemp variable, then I add a diagnosa variable like this
$nama_diagnosa=Laporan::ViewDataDiagnosa($cell['id_pasien'],$cell['tgl_rekam']);
$diagnosa = '';
foreach ($nama_diagnosa as $cellDiagnosa){
$diagnosaTemp=$cellDiagnosa['nama_diagnosa'];
$diagnosa=$diagnosa.",".$diagnosaTemp;
} echo $diagnosa;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am using directory_map to get the images inside the folder. But i want to show the images by date modified (in descending order) below is my code
$dir = realpath(FCPATH) . "/assets/images/articles/";
$map = directory_map($dir);
Is there any way to show files in descending order or to get the file info?
I don't see you defining $to anywhere in those lines you posted.
few variables r missing in ur code..
<?php
//these r missing into ur code
$mobile = $_POST['mobile'];
$address = $_POST['address'];
$remarks = $_POST['remarks'];
$to = "abcd#abcd.com";
?>
Could you mention the error please ...?
Also there is no $to variable defined in the code in mail.php
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I just recently created this little piece of code, altrought its pulling me the error you can see in the title.
This is the code..
<?php if($comment_count->num_rows = 0)
echo '<div class="CenterText"><p>No Comments Yet</p></div>';
$comment_count variable -
$id = $_GET['id'];
$comment_count = $db->query("SELECT * FROM comments WHERE post_id = '$id'");
$db variable-
$db = mysqli_connect('localhost','--','pw','--') or die('error with connection');
?>
This is probably something really stupidly small, But I can't find the reasoning for it. Thanks for help!
Your IF condition has assignment operator instead of equality operator.
change
<?php if($comment_count->num_rows = 0)
to
<?php if($comment_count->num_rows == 0)
May be this is the issue? Try it.