bracket is lost in PHP code [closed] - php

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)){

Related

PDO Variable Update Error [closed]

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());
}

Error in mysqli_num_rows [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
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)

Any idea why my code keeps producing syntax error? [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 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

I have the error "Parse error: syntax error, unexpected 'echo' (T_ECHO)" [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
This is my code:
<?php
include 'connect.php';
?>
<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);
if ($email == "")
(
echo "No has puesto la contraseña<br>";
echo " <A href='register.php'>Go back</a>";
exit;
I am getting this error:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\wamp\www\game\reguser.php on line 15
I tried to add ";" after if ($email == "") but nothing changes. I've changed brackets all over and am now out of ideas.
After the if clause, use braces { to introduce the code block and not (
if ($email == "")
{
echo "No has puesto la contraseña<br>";
echo " <a href='register.php'>Go back</a>";
exit;
}
The if statement in PHP needs { } brackets, not ( ). So your code is
if ($email == ""){
echo "No has puesto la contraseña<br>";
echo " <a href='register.php'>Go back</a>";
exit;
}

Count rows with two values mysql (PHP Error) [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 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());
}
?>

Categories