file_exists doesn't find image with Cyrillic name [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have this image "Трислоен-паркет.png" and this to check if it exists:
$imgs='../images/pc/'.clear_string($categoryrow[1],$tr).'.png';
if(file_exists($imgs)){ echo 'yes';
}else echo 'no';
It always returns NO.
The strange thing is that if I call the image without check if it is exists - it shows the image but I need to DO check and show that image if exists, otherwise I will show default image..but file_exists does wrong ..
clear_string function only removes white spaces and commas and some other type letters..
how to avoid it?

You can use iconv to set the language format you pass to the functions such as file_exists.
Your code might look something like this:
file_exists(iconv('iso-8859-5', 'utf-8', $imgs));

The problem was that file_exists checks starting from root and in this case the path was wrong.. no encoding was needed.. Sorry guys for taking your time and thanks for your answers !..

Related

What does " if(true) " means? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm building a functionality which displays a message dynamically, i.e if the forms are correctly filled or not.
I came across this piece of code and I don't understand how does it really work.
if(true) {
$this->flash('Yay ! File uploaded successfully', 'success');
} else {
$this->flash('There is some error', 'error');
From what I've already looked for, I guess it's used to see whether or not there is an array available, since PHP returns false if there isn't one.
(according to PHP manual )
I still don't get how does this work, there is no variables such as if($foo) but just plain boolean on this condition.
And yes, it seems to work as intended.
Thanks for your enlightments.
This looks like a debugging statement left in.
if(true)
This is always true, so you could remove the test entirely and just run with the true statement.

Image Source to Include a PHP Input [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers

PHP comparing two POST not working [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm currently having an issue with PHP, I'm trying to compare two POST variables using an if statement. However when i use != it will not work, but == will work and i don't understand why.
if($_POST["PasswordSignUp"] != $_POST[PasswordSignUpRepeat]){
setcookie("PassMatch","Error");
}
Edit:
Okay, i just had an idea that may fix my problem, at the moment i am using the cookie as basically a global variable. Is there a way to define a global variable to use from page to page without having to 'include' or 'require' it into the code.
$_POST[PasswordSignUpRepeat] should be $_POST['PasswordSignUpRepeat']. Also, use paranthesis in comparison. It isn't mandatory, but it's a good process to follow.
if(($_POST["PasswordSignUp"]) != ($_POST['PasswordSignUpRepeat'])){
setcookie("PassMatch","Error");
}
Try below:-
if($_POST['PasswordSignUp'] !== $_POST['PasswordSignUpRepeat']){
setcookie("PassMatch","Error");
}
!== will check fr value and type.

delete() versus unlink() to delete file in PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
The title says it all. What would be the most performance-friendly way to delete a file? Using PHP's unlink()-function, or PHP's delete()-function?
There is no delete function to delete files. As the documentation states:
This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place.
The links on that page will lead you to the correct function for deleting a variable (unset) or deleting a file (unlink).

Using a PHP location header [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am trying to use a variable in a PHP location header, but I can't seem to get it to work. What am I doing wrong?
My Code:
$id= 14;
header('Location:collection.php?idollection=$id);
Just by assumptions.. You want to re-direct with a $_GET value based on a variable source?
How about:
$id = 1;
header("Location: collection.php?idollection=".$id);
exit;
Use of the exit will make sure the page will not continue executing after header has been called. Furthermore, make sure that there is no whitespaces or any output prior to the header being called.
Make sure to use double quotes. You used single quotes and actually only used one. Try this:
header("location:collection.php?idcollection=$id");

Categories