This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I keep getting a T_Variable exception when running this PHP code hosted on an online database. Am not really the expert at PHP, but maybe one of you can spot the error.
thanks,
Here is the code:
$wind = "deep34"; //error thrown here. When I delete this variable. //Error jumps to $name
$name = "6";
$sql = "select *from students where deviceid = '$name' and alpha = '$wind';";
Dont use semicolon at the end of the statement
$sql = "select * from students where deviceid = '$name' and alpha = '$wind'";
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 4 years ago.
I am getting this message
Parse error: syntax error, unexpected '$username' (T_VARIABLE) in
C:\wamp64\www\tutorial\register_parse.php on line 9
when trying my own register for forum. I can figure out what ive done wrong.
here is the code:
<?php
include("connect.php");
$username = $_POST["username"];
$password = $_POST["password"];
$sql = "INSERT INTO forum.users(username,password)
VALUES("$username","$password"); ";
$res = mysql_query($sql);
if($res){
echo "Successfully registered as: ".$username;
}
else{
echo "failed to register, please try again </br>";
echo "ERROR: ".mysql_error();
}
?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
include('Connect.php')
$sql = "insert into medicaments values ('$_REQUEST[code_med]','$_REQUEST[name_med]', '$_REQUEST[exp_date]','$_REQUEST[qte_med] ')";
mysqli_query( $sql , $con);
echo " Record Inserted Successfully = " . mysqli_affected_rows($con);
mysqli_close($con)
after include('Connect.php') add ; like this include('Connect.php');
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I am newbie and learning php yet. I am trying to run some mysqli_query but its giving me some errors. My code is like below.
<?php
ob_start();
include("db.php");
$result = mysqli_query($conn,"SELECT * FROM contest");
while($row = $result->fetch_assoc()){
if($row['automated'] ==1){
echo 'Atomatic is enabled';
$result1 = mysqli_query($conn,"UPDATE `contest` SET automated =0"
$new = mysqli_query($conn,$result1);
echo 'Atomatic is Disabled';
}
else{
echo 'Atomatic is Disabled';
}
}
can somebody check and please suggest me whats wrong in this query ? its giving me error like Parse error: syntax error, unexpected '$new' and similar if I change it. Thanks
Close patenthesis.()..
$result1 = mysqli_query($conn,"UPDATE `contest` SET automated =0");//error was here
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Can anyone help me take a look? I want to fetch a number out but i get this error
Parse error: syntax error, unexpected ';', expecting ']' in E:\Software\Xampp\htdocs\pme\main\user_online.php on line 12
here is my code
<?php
include '../config.php';
$sql= mysqli_query($connection,' select * from session');
$row = mysqli_num_rows($sql);
while($extract = mysqli_fetch_array($sql)){
echo
"<div class='left-total-user-online' id='left-total-user-online'>
total user online : " .$extract[$row = mysqli_num_rows($sql);]. "</div>";
}
?>
You are making life much more complicated than is necessary. All you need to code is
<?php
include '../config.php';
$sql= mysqli_query($connection,' select * from session');
$row = mysqli_num_rows($sql);
echo "<div class='left-total-user-online' id='left-total-user-online'>
total user online : $row</div>";
}
?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
Can anybody tell me what is wrong with my code? I cant seem to solve this error:
Parse error: syntax error, unexpected 'mytable' (T_STRING) in E:\XAMP server\htdocs\fyp\login.php on line 11
<?php
$user = ‘minzhe’;
$pswd = ‘2818327’;
$db = ‘trial’;
$conn = mysql_connect(‘localhost’, $user, $pswd);
mysql_select_db($db, $conn);
$un = $_POST['username'];
$pw = $_POST['password'];
$query = “SELECT * FROM mytable WHERE username = ‘$un’ AND password = ‘$pw’”;
$result = mysql_query($query);
if(mysql_num_rows($result) >0)
echo 1;
else
echo 0;
?>
Don't use a word processor to edit your code:
$user = ‘minzhe’;
^------^
You've got "smart quotes" everywhere, and they are NOT valid quotes in PHP. They have to be ' or ".
You are also vulnerable to sql injection attacks.
your computer is defaulting to curvy quotation marks. which PHP cannot read;
“ should be replaced with "
and ‘ should be replaced with '