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 5 years ago.
Improve this question
I'm trying to establish a new PDO instance with the following code
<?php
$handler = new PDO(“mysql:host=127.0.0.1;dbname=database”,
“root”, “”);
I get the following error message:
Parse error: syntax error, unexpected ':', expecting ',' or ')' in /Applications/XAMPP/xamppfiles/htdocs/example/connection.php on line 2
There has been no problems like this before until I attempted to do this on a new Mac. Can someone help with this issue?
try this:
$handler = new PDO("mysql:host=127.0.0.1;dbname=database",
"root", "");
your quotes were wrong
You should to this:
<?php
$handler = new PDO("mysql:host=127.0.0.1;dbname=database","root", "");
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 7 years ago.
Improve this question
I have two PHP scripts, dispatcher.php and processor.php (there are more, but I've commented the others out because they're not necessary at the moment).
I get the following error:
Parse error: syntax error, unexpected '$this' (T_VARIABLE) in /----home directory-----/classes/processor.php on line 12
Here's the code for processor.php:
class Processor{
protected $player;
protected $name;
protected $id;
function __construct(){
}
function loadvars($request){
$this->loadvar($this->name, $request, "name");
}
private function loadvar($target, $request, $name){
if(isset($request[$name])){
$target = $request[$name];
}
else{
$target = "";
}
}
}
this is the code for dispatcher.php:
require('classes/processor.php');
$test = new Processor();
$test->loadvars($_GET);
I don't see why this error occurs?
I'm coding using Sublime on Windows, if that matters.
Fixed it!
Try retyping the file if you have weird parse errors. I copied the code back from StackOverflow (where I typed it above) and it worked. Guess some unparseable character got into the file somewhere.
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
Since installing Mac OSX El Capitain, I am getting a parse error. The code works fine on the server, but on my development workstation, I get this error consistently.
Parse error: parse error in /Library/WebServer/Documents/website/includes/config.php on line 4
// Calling code snippet:
include("includes/navbar.php");
require_once("includes/config.php");
$servername = DBHOST;
$username = DBUSER;
$password = DBPASS;
$database = DBNAME;
config.php file:
<?php
/* Config File for Common Values */
define ("DBHOST", “127.0.0.1:3306”); <--- This is line 4
define ("DBUSER", “userid”);
define ("DBPASS", “password”);
define ("DBNAME", “database”);
?>
You're using smart quotes (“ and ”) where you should have straight quotes ("). Replace the smart quotes with straight quotes. For example, change
“127.0.0.1:3306”
to
"127.0.0.1:3306"
Do the same with each of the other define() statements.
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 this error message on windows vps.
Complete error message:
"Parse error: syntax error, unexpected T_DNUMBER in C:\Inetpub\vhosts\kayahomesonline.com\httpdocs\configuration.php on line 24"
My configuration.php content is:
error_reporting(E_ALL);
ini_set("display_errors", 1);
session_start();
## Set the time for IST
date_default_timezone_set('Europe/Istanbul');
setlocale(LC_ALL, 'turkish');
setlocale(LC_ALL, 'tr_TR.UTF-8');
// setlocale(LC_TIME, 'tr_TR');
$title = "KAYAHOMES YÖNETİM PANELİ";
$baseURL = "https://www.kayahomesonline.com";
$basePath = "C:\Inetpub\vhosts\kayahomesonline.com\httpdocs\";
## JavaScript General Path
$js_path = 'http://script.rezsis.com/js/';
$img_path = 'http://script.rezsis.com/images/';
$version = "0.1";
$baglan = mysql_connect('localhost','datauser','D4t4b4s3*');
if (!$baglan)
{
die('Veritabanına bağlanılamadı... Lütfen yetkilinizle irtibata geçin...' . mysql_error());
}
mysql_select_db('kayahomes_new',$baglan) or header("Location: ../login.php");
mysql_query("SET NAMES UTF8");
?>
what is wrong? This config file is working on my old Linux VPS.
As #deceze pointed out the string is not ending here in the variable $basePath. You would need to add a backslash to make the string an end.
So the code would be like
$basePath = "C:\Inetpub\vhosts\kayahomesonline.com\httpdocs\\";
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 been trying to put up a small testing site for a project at codebase.host22.org, and I cant seem to get my PHP script to work. The script is hown as follows:
<?php
$browser = get_browser(null, true);
$data = $browser[browser]
$f = fopen("data.csv", "a");
fwrite($f, $data = ",");
fclose($f);
?>
I don't see a problem. But I get this error when trying to visit the page:
Parse error: syntax error, unexpected T_VARIABLE in /home/a5547326/public_html/index.php on line 6
My hosting is with 000webhost. Is there a problem with my code or the server?
You missed semicolon after $data variable.
$data = $browser[browser];
You're missing the quote and the semicolon:
$data = $browser['browser'];
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
Here is my code inside of a function:
list(${$page}Records, ${$page}MetaData) = getRecords(array(
'tableName' => $page,
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
Problem is, the very first line of it throws this error :
Parse error: syntax error, unexpected T_STRING, expecting ',' or ')' in /[edited]/includes/functions.php on line 10
I've tried a bunch of different ways of going about this but I don't know much about PHP. Anyone know what's going on here?
${$page}Records
This is not how you use variable variables. PHP has no idea what you mean with Records there.
Try this:
${$page.'Records'}
PHP will run the code inside the {} and use that string as a variable name.