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
So I'm trying to fetch a value from a table in my database into a placeholder for an html input element. Code is as follows:
<input type="text" name="timesats" placeholder="
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
$result = mysqli_fetch_object($query);
echo($result);
?>
">
$dbc contains the values for connection.
I'm getting no errors so its really hard to debug. The value from the table is not null.
Try
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
while ($obj = mysqli_fetch_object($query)) {
$ph = $obj->timesats;
}
?>
<input type="text" name="timesats" placeholder="<?php echo $ph; ?>"/>
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 get this erro: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\PHP\tennis\ronde2-wijziging.php:59
// code van het knop wijzigen
if(isset($_POST['wijzig'])){
$id = $_POST['id'];
$speler1 = $_POST['speler1'];
$speler2 = $_POST['speler2'];
$uitslag1 = $_POST['uitslag1'];
$uitslag2 = $_POST['uitslag2'];
$datum = $_POST['datum'];
$veld = $_POST['veld'];
//UPDATE: gegevens in de form wijzigen.
$sql = "UPDATE ronde1 SET speler1 = :speler1, speler2 = :speler2, uitslag1 = :uitslag1,
uitslag2= :uitslag2, datum= :datum, veld= :veld WHERE id=:id";
$stmt = $pdoConnect->prepare($sql); //stuur naar mysql.
$stmt->bindParam(":id", $id );
$stmt->bindParam(":speler1", $speler1 );
$stmt->bindParam(":speler1", $speler1 );
$stmt->bindParam(":uitslag1", $uitslag1 );
$stmt->bindParam(":uitslag2", $uitslag2 );
$stmt->bindParam(":datum", $datum );
$stmt->bindParam(":veld", $veld );
$stmt->execute();
// $_SESSION['message'] = "Speler is gewijzigd";
// $_SESSION['msg_type'] = "warning";
header("location: #.php");
exit;
}
I want to update my data.strong text
My solution worked but didn't explain why it did go wrong in the first place. The user dpant explains in the comments why your code snippet was not working.
Credits go to him
dpant:
Most probably the problem with your original code was that you were binding the :speler1 parameter twice (the :speler2 parameter was never bound). This was just a typo in your code. Take a close look at it.
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
Im getting query error, im using the like LIKE sql function to search for the name submitted by the user.
But msqli_query is giving an error if i remove the LIKE function it works but doesn't works with the LIKE function
<!DOCTYPE html>
<html>
<head>
<title>Search Users</title>
</head>
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"method="GET">
Name: <input type="text" name="name"></input>
<input type="submit" name="searchusers" value="Submit"></input> </br>
</body>
</html>
<?php require('connect.php');
$name = #$_GET['name'];
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
$select123 ="SELECT username FROM users WHERE username LIKE ='%".$name."%'";
$check = mysqli_query($conn, $select123) or die("query error");
mysqli_num_rows($check) or die("Couldnt not find the Specified username");
}
?>
Please help
Remove = near keyword like :
$select123 ="SELECT username FROM users WHERE username LIKE '%".$name."%'";
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 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 try many times but I'm not sure why I get error saying that "Fatal error: Function name must be a string in view_registration2.php on line 8". Can someone tell me whats wrong? Did I use wrong syntax somewhere? Thank you :)
//This is my other php file
//<FORM name="form1" method ="POST" action="view_registration2.php" >
//<select name="semester">
// <option value="" selected> -- choose which semester you want to list --
// <option value="06072">06072
// <option value="06071">06071
//</select>
//<INPUT type="submit" name="button1" value="Submit">
$sem = $_POST("semester"); //line 8
echo $sem;
require_once("dbconn.php");
$query1 = mysql_query("select * from student");
if(!$query1) die("SQL query error encountered : " . mysql_error() );
$matrik1= array(); $nama1 = array();
while($record = mysql_fetch_array ($query1))
{
$matrik1[]=$record['matric'];
$nama1[]=$record['name'];
}
The $_POST superglobal is an Array, not a function. You access its indexes with square brackets [] not parenthesis ().
$sem = $_POST["semester"];