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
i have the if statement below i am trying to make sure that the variable client2 is not empty before doing the update, as the update has to be performed to that client, but ever time i uncomment the if statement it gives a white screen
if(!empty($client2)
{
mysqli_query($con,$query) or die ("Could not update ");
header('Location: preview.php?=client=$client');
}
what i would like is for it not to produce a white screen i suspect it is minor error i have overlooked
the problem also existed before i added
header('Location: preview.php?=client=$client');
this was added as it the final step it needs to do after doing the update but i will have to add a check in to display the error if it fails the update before doing the header but for now i am focusing on getting it to do the update regardless of mysql errors
Your header is wrong you should do it like this:
header("Location: preview.php?client=$client");
You've also forgot a ) here:
if(!empty($client2))
You do miss a closing bracket in your if. Empty is a function and needs to be opened and closed with brackets (). As is the IF function. In other words, you don't close your IF function so PHP assumes that everything after emtpy() is still part of the IF closure.
Also, try never working (in development env ofc) without display_error being abled.
Besides that, your header function has a '=' after the question mark. Its not needed and will eventually fail.
Related
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 a PHP form that when loads will get some variables. Not all variables are set. In the code I can see if the Variable has been defined by using strlen() and that seem to be working but when I apply an if statement it doesn't seem to work?
GetSettingValue() is a function to get the value in a file, the item in the file might not exist
the code I have tried is:
if (strlen(GetSettingValue("Latitude"))==0);{
logEntry("Lat== 0");
}
Just prior to this statement I print the results of strlen(GetSettingValue("Latitude")) and it displays 0 (this is the expected result) And the logEntry gets processed.
But if I want to not enter the if statement I used:
if (strlen(GetSettingValue("Latitude"))!=0);{
logEntry("Lat== 0");
}
and the results of strlen(GetSettingValue("Latitude")) right before the if statement shows 0
But the code will process the logEntry. It seems like the result of strlen() doesn't matter?
Any ideas or a better method?
Just remove the ; semicolon after the parenthesis and it'll work absolutely fine.
Correction:
if (strlen(GetSettingValue("Latitude"))!=0) { logEntry("Lat== 0"); }
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.
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.
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 !..
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");