Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
The last if condition is ignored whereas one or both variables are equals to 0, can you explain me why ?
<?php
require('../controller/env.php');
$countexisting=0;
if(!isset($_GET['idkey'])){
header('location:../index.php');
exit();
}else{
$idkey=$_GET['idkey'];
$request=$db->prepare('SELECT * FROM testimonials WHERE idkey=?');
$request->execute(array($idkey));
while ($exist=$request->fetch()) {
$countexisting+=1;
$activelink = $exist['activelink'];
}
if($countexisting=0 || $activelink=0){
header('location:../index.php');
exit();
}
}
Thanks !
Missed the "==".
if($countexisting==0 || $activelink==0){
header('location:../index.php');
exit();
}
it's working fine now!
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 4 years ago.
Improve this question
Parse error: syntax error, unexpected '{'
Plz, I wonder Can you help me, I can't find it.
if( isPost() ) {
extract($_POST);
if( validation_required([$name , $family ,$username , $email , $password]) ) {
$conn = connectToDB();
if (!userGet($username,$conn){
saveUsers($_POST) ? redirect("index.php") : $status = 'you are failed';
} else {
$status = "This username is exist";
}
} else {
$status = 'your information is not valid';
}
}
It's line 5:
if (!userGet($username,$conn){
Should have 2 closing brackets
if (!userGet($username,$conn)){
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
these are my query codes. Please help me.
PDO Error: Array
PDO Eror Code: 00000
<?php if ($_POST){
$title = trim($_POST['title']);
$content = trim($_POST['content']);
$id = $_GET['id'];
$save = $PDO->prepare("UPDATE `news` SET `title` = :title WHERE `id` = :id");
$save->execute(array(
"title" => $title,
"id" => $id
));
print_r("Error: ".$save->errorInfo());
print $save->errorCode();
}
?>
It the OK status code.
You always print error but you should to print that only when the query failed.
$sql = $save->execute(...)
if ($sql === FALSE) {
print ('Error: ' . $save->errorCode());
}
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
What's wrong with this code:
<?php
session_start();
if(!isset($_SESSION['username']) && isset($_COOKIE['username'], $_COOKIE['password']))
{
$checkQuery = "SELECT password, id FROM accounts WHERE username='".$db->real_escape_string($_COOKIE['username'])."'";
$checkResult = mysqli_query($db, $checkQuery);
$check = mysqli_fetch_array($checkResult);
if($check['password'] == $_COOKIE['password'] && mysqli_num_rows($checkQuery)>0)
{
$_SESSION['username'] = $_COOKIE['username'];
$_SESSION['userid'] = $check['id'];
}
}
?>
It shows this error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result,
string given...
Looks like you should change
mysqli_num_rows($checkQuery)
to
mysqli_num_rows($checkResult)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
<?php
if (isset($_POST['preview'])){
echo $user = $_SESSION['ue'];
echo $title=$_POST['title'];
echo $dis=$_POST['dis'];
echo $a=$_POST['a'];
echo $b=$_POST['b'];
echo $c=$_POST['c'];
echo $d=$_POST['d'];
echo $timespan=$_POST['timespan'];
$sql="INSERT INTO survey (user, title, description, opta, optb,optc,optd) VALUES ('$user','$title', '$dis', '$a' , '$b', '$c', '$d','timespan')";
if (mysqli_query($con,$sql))
{
echo "Success";
}
else
{
echo "Error: " . mysql_error();
}
mysqli_close($con);
}
?>
Here is my code, all post variables are showed on web page, while data is not inserted in database table. also it does not show any error or exception.
INSERT INTO survey (...) - there is 7 columns
VALUES (...) - and you are sending 8 variables
You didn't escape your $_POST variables
Your connection to database is missing
mysql_error() will not show the errors thrown by the MySQLi functions
There are too many values added: 8 instead of 7
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to query the db in php and get if there is a match / success but it's not resulting in success although it should so I've thinking there's a syntax error?
Here is the code:
if ($db_found) {
$SQL = "SELECT * FROM wp_users where user_login='.$user.'";
$result = mysql_query($SQL);
//Check if theres a match
if $result > 0 {
echo 'There was a match';
}
...
}
if (mysql_num_rows($result)) {
echo 'match';
}
if (mysql_num_rows($result)==1) {
echo 'There was a match';
}