Where's my issue here? (PHP/PDO) - User exist [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
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.
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.
Improve this question
trying to check whether a user exists or not via pdo
$wantedusrnm = $_POST['new-usrnm'];
$userExist1 = "SELECT * FROM users WHERE username=:wantedusrnm";
$userExist = $handler->prepare($userExist1);
$userExist->execute(array(':username' => $wantedusrnm));
$userExist = ($userExist->rowCount());
for some reason it errors, dunno why, any reasons?

Change:
$userExist->execute(array(':username' => $wantedusrnm));
To:
$userExist->execute(array(':wantedusrnm' => $wantedusrnm));
Because, in your query you've got :wantedusrnm but in your execution array you've got :username.

Related

Include path with constant and variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
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.
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.
Improve this question
I'm trying to include a file to current php page but the name of the file depens on the lang.
This line does not work:
include_once PATH.'lang/'.$_SESSION['lang'].'.php';
How can I achieve that?
Your problem should be the "PATH". It must be a string to concatenate with the other strings. For example:
include_once '/sites/all/files/'.'lang/'.$_SESSION['lang'].'.php';
Also be careful with the slashes that make your path to the file.

Parse error: syntax error, unexpected '$query' (T_VARIABLE) in model_role.php on line 10 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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.
Improve this question
i tried to debug it but i really don't know what's causing the error. i already traced the missing brackets but i think there's none. so please help!
<?php
class Model_role extends CI_Model {
public function scalar($user_account, $role){
$this->db->where('login_id', $this->input->post('idnum'));
$this->db->select($role); z
$query = $this->db->get($user_account);
$row = $query->row_array();
return $row['role'];
}
}
?>
It looks like there's a stray z way to the right of $this->db->select($role); Can you search for z in your editor and see if it comes up?

PHP error for login session [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
I have an error in a single line of code but I can't seem to find it. I've tried changing the quotes to all match but that doesn't do anything. Please help. here is where the error is
$managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]);
try this :
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]);
btw i dont know what you are trying to do i just solved your syntax error ;)

PHP PDO Wrong numbers of tokens? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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.
Improve this question
Can someone tell me what is wrong with that statement cause I do not see any mistake?
$PrevReleaseModel = $con->prepare("SELECT * FROM model WHERE model_name=:model_name AND model_release:model_release");
$PrevReleaseModel->bindParam('model_name',$model_name);
$PrevReleaseModel->bindParam('model_release',$model_release);
$PrevReleaseModel->execute(array('model_name'=>$model_name,'model_release'=>$model_release));
I am really confused.
WHERE model_name=:model_name AND model_release = :model_release
You missed a equal sign in the last condition.
You may try this out:-
$PrevReleaseModel = $con->prepare('SELECT * FROM model
WHERE model_name = :model_name AND
model_releas = :model_releas'
);
$PrevReleaseModel->bindParam(':model_name', $model_name, PDO::PARAM_STR);
$PrevReleaseModel->bindParam(':model_releas', $model_release, PDO::PARAM_STR);
$PrevReleaseModel->execute();

Confused about PHP syntax error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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.
Improve this question
I am following video tutorials on the Internet, and this is one of them. However, I am getting a syntax error and can't find where it is.
<?php
function hesapla($ilktarih,$sontarih){
$yil=$son-$ilk;
$ay=$yil*12;
$gun=$ay*30;
return array("$ilktarih","$sontarih","$yil","$ay","$gun");
}
$ilktarih=$_POST["ilk"];
$sontarih=$_POST["ikinci"];
hesapla($ilktarih,$sontarih);
list ("$ilktarih","$sontarih",$yil,$ay,$gun)=hesapla($ilktarih,$sontarih);
?>
Remove double quotes from list variables like this :
<?php
function hesapla($ilktarih,$sontarih){
$yil=$son-$ilk;
$ay=$yil*12;
$gun=$ay*30;
return array("$ilktarih","$sontarih","$yil","$ay","$gun");
}
$ilktarih=$_POST["ilk"];
$sontarih=$_POST["ikinci"];
hesapla($ilktarih,$sontarih);
list ($ilktarih,$sontarih,$yil,$ay,$gun)=hesapla($ilktarih,$sontarih);
?>

Categories