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
New PHP programmer here. Need some syntax help.
Like I know what im trying to do, here, check if that session variable is set and if its a certain string value, but the "(" you need for isset is messing the syntax up. I can't find the help im looking for via google for what is really a very simple syntax question, so I had to come here.
if (isset($_SESSION['IsValid'] AND $_SESSION['IsValid']=="Yes")) {
}else{
}
Typos:
if (isset($_SESSION['IsValid']) AND $_SESSION['IsValid']=="Yes") {
^---missing ^---only one ) here
isset() is a function and checks a SINGLE variable if it "exists". You're trying to isset() the result of your AND operation, which is illegal syntax.
if( isset($_SESSION['IsValid']) && $_SESSION['IsValid'] == "Yes" ) {
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 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
if(!isset($aProdcut[$eachYear][$store][$base])){
$aProdcut[$eachYear][$store][$base] = 0;
}
$aProduct[$eachYear][$store][$base] += $row['total_price'];
Undefined index: MARC. MARC is from $base.
Who can give me some hints?
You have a typo there $aProdcut vs $aProduct
The code should not result in undefined index if you have an $aProduct variable, which is an array and has an index value of $eachYear, which is, in turn another array, which has an index value of $store, since, in that case
isset($aProdcut[$eachYear][$store])
is true. If that is true and it does not have a $base index value, then it is created and initialized with 0. Later, when you use it, it will surely exist. So, the issue is probably that $aProduct[$eachYear] does not exist or $aProduct[$eachYear][$store] is not set. Make sure that everything exists, not just the innermost index and then the problem will be probably fixed. If the problem still persists, then you should check whether some other things are causing it, like multi-threading.
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 8 years ago.
Improve this question
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){
echo (kat['id_categories']);
}
table cols and values are all matched, something is wrong in this part of code
I tried adding $ before kat and using only one "=", sill doesnt work
NEW LINK
http://pastebin.com/RPK7vEaJ
this
where id_kartes===".$card['id']."
would be
where id_kartes=".$card['id']."
and missing $
echo $kat['id_categories'];
so full code :-
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){
echo $kat['id_categories'];
}
best practice if you store your query result in a variable and loop over this variable.
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)
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");