This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I wrote my code like this
<?php
$dbCon = mysqli_connect("localhost" "XXXXXXXX" "XXXXXXXXX" );
if(mysqli_errno()){
echo "Cannot connect:" .mysqli_connect_error();
}
?>
but this is my error
Parse error: syntax error, unexpected '"XXXXXXXX"' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\Project\connection.php on line 2
You need commas to separate the parts in your connection:
$dbCon = mysqli_connect("localhost", "XXXXXXXX", "XXXXXXXXX" );
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 3 years ago.
My first php file and encountered this. Help! On line 2 there seem to be a problem and I need to submit my work soon. I am in real need of help.
<?php
require_once '../workspace/dboperation.php';
$response= array();
if($_SERVER['REQUEST_METHOD']=='POST')
{
if(isset($_POST['username'])and
isset($POST['email']) and
isset($POST['password'])
)
$db= new dboperation();
if($db->createUser(
$_POST['username'],
$_POST['email'],
$_POST['password']
)){
if(isset($_POST['username'])and
isset($POST['email']) and
isset($POST['password'])
) <==== YOU MISSED `{`
$db= new dboperation();
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 3 years ago.
I want to display the table categories with PHP code, but displays the error:
Parse error: syntax error, unexpected end of file in
W:\domains\test.ru\index.php on line 15.
What to do?
CODE:
<?php
$connection = mysqli_connect('127.0.0.1', 'root', '19912005', 'test_bd');
if($connection = false){
echo 'Не удалось подключится к БД!';
exit();
$result = msqli_qery($connection, "SELECT * FROM `categories`");
$r1 = mysqli_fetch_assoc($result);
print_r($r1);
?>
put the code below inside your codes, it is going to work
if($connection = false){
echo 'Не удалось подключится к БД!';
exit();
}
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 7 years ago.
I'm pretty new to PHP, and after typing up a few lines and testing I ran into an error that I have no idea on how to fix:
Parse error: syntax error, unexpected T_VARIABLE in /home/nil/public_html/php/getuids.php on line 10
<?php
$connection = mysql_connect("localhost", "root", "") or die("connection unsuccessful");
mysql_select_db("nil_chatModerators")
$query = "SELECT * FROM moderators";
$result = mysql_query($query);
echo $result;
mysql_close();
?>
Here's a screenshot of everything from phpMyAdmin:
(can't post images yet..) http://i.imgur.com/LG4Km33.png
Thanks for any help in advance!
Semicolon missing in line 4. See my updated code
<?php
$connection = mysql_connect("localhost", "root", "") or die("connection unsuccessful");
mysql_select_db("nil_chatModerators");
$query = "SELECT * FROM moderators";
$result = mysql_query($query);
echo $result;
mysql_close();
?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
When I run this code:
<?php
$reuser = $_GET['ruser'];
$mail = $_GET['msg'];
$sender = $_GET['senderr']
$connection = mysql_connect("localhost","root");
mysql_select_db("final");
if(!$connection){
die('could not connect:'.mysql_error());
}
$sql = "INSERT INTO mails (sender,to,message,)
VALUES ('$sender','$reuser','$mail')";
mysql_query($sql) or die("error".mysql_error());
mysql_close($connection);
?>
I get this error:
Parse error: syntax error, unexpected '$connection' (T_VARIABLE) in C:\xampp\htdocs\final\newmail.php on line 7
I don't know what the problem is – can anyone help me please?
You're missing a semi-colon at the end of this line:
$sender = $_GET['senderr']
It should be:
$sender = $_GET['senderr'];