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 have the following code, but for some reason I am getting an unexpected T_Variable. I can't seem to figure out where I am getting the error at. Any assistance will be greatly appreciated. Thanks
<? php
$status = mysql_query('SELECT count(*) FROM AHG WHERE `Survey Tech Initials` = 'Jeff' AND completed = 'yes');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
See below
<? php
$status = mysql_query("SELECT count(*) FROM AHG WHERE `Survey Tech Initials` = 'Jeff' AND completed = 'yes'");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
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 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
Please im trying to insert data from a table to another. the issue is that i find duplicate records in database when applying the code below:
<?php
include ('lib/connexion.php');
$id_article = $_GET['num'];
$requete = "Select * from products where product_id=$id_article";
$resultats = mysql_query ($requete);
if($resultats === FALSE) {
die(mysql_error()); // TODO: better error handling
}
?>
<html>
<head>
<title>APP crud</title>
</head>
<body>
<?php
while ($ligne =mysql_fetch_array ($resultats)){
$sql2 ="INSERT INTO panier (product_title, description, prix)
VALUES ('".$ligne[1]."','".$ligne[2]."','".$ligne[3]."' ) ";
mysql_query ($sql2) or die ('Erreur : ' .mysql_error());
$resultats2 = mysql_query ($sql2);
if($resultats2 === FALSE) {
die(mysql_error()); // TODO: better error handling
}
header('Location: panier.php');
?>
Supprimer
Modifier
Ajouter
Retour
<?php } ?>
</body>
<html>
Can someone tell me why this happens? thanks.
Making this as a community wiki (I've nothing to gain here, or wanting to gain) and pulled from comments to close this with:
Because, you're doing this twice: mysql_query ($sql2)
"Remove this line mysql_query ($sql2) or die ('Erreur : ' .mysql_error()); – devpro"
and
"Mysql_ is deprecated use mysqli_* or PDO – devpro"*
and
"you could also ALTER your column(s) as UNIQUE. That will guarantee that no duplicates ever gets inserted."
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 can't seem to find where either a semi colon or a "}" is needed
for ($period=1; $period<6; $period++)
{
echo "<tr><td>".$period."</td>";
for ($room=0; $room<sizeof($rooms_array); $room++)
{
$sql = "SELECT Username FROM Booking WHERE RoomID ='".$rooms_array[$room]."' AND Period = '".$period."' AND Date = '".$sentdate."'";
$result= sqlite_query($con,$sql);
$row = sqlite_fetch_array($result);
if($row['Username']==$_SESSION['Username'])
{
echo "<td>Booked By ".$row['Username']."</td>"
}
}
}
?>
You need a semicolon after your echo statement:
{echo "<td>Booked By ".$row['Username']."</td>";}
Errors like this might be easier to find if you adopted a clearer block/indent style. Your code is pretty hard to read.
For example:
for ($period=1; $period<6; $period++)
{
echo "<tr><td>".$period."</td>";
for ($room=0; $room<sizeof($rooms_array); $room++)
{
$sql = "SELECT Username FROM Booking WHERE RoomID ='".$rooms_array[$room]."' AND Period = '".$period."' AND Date = '".$sentdate."'";
$result= sqlite_query($con,$sql);
$row = sqlite_fetch_array($result);
if($row['Username']==$_SESSION['Username'])
{
echo "<td>Booked By ".$row['Username']."</td>";
}
}
}
Missing ; here:
{echo "<td>Booked By ".$row['Username']."</td>"}
^
echo "<td>Booked By ".$row['Username']."</td>" is missing a semicolon