tatarrr 0 / 0 / 0 Регистрация: 14.02.2013 Сообщений: 108 |
||||
1 |
||||
02.11.2014, 20:36. Показов 2753. Ответов 2 Метки нет (Все метки)
Выдает ошибку syntax error, unexpected T_LOGICAL_OR на 16 строке
Добавлено через 25 минут
__________________
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
02.11.2014, 20:36 |
Ответы с готовыми решениями: Ошибка в php скрипте: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Выборка из двух таблиц: Parse error: syntax error, unexpected T_STRING in
Mysql_result непонятная ошибка Parse error: syntax error, unexpected ‘,’ Parse error:… 2 |
3102 / 2587 / 1219 Регистрация: 14.05.2014 Сообщений: 7,231 Записей в блоге: 1 |
|
02.11.2014, 20:41 |
2 |
tatarrr, в конце 15-ой точку с запятой уберите, и будет Вам счастье.
0 |
Dolphin |
02.11.2014, 22:37
|
Не по теме:
и будет Вам счастье Не будет
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
02.11.2014, 22:37 |
PHP Parse error: syntax error, unexpected ‘text’ (T_STRING) Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STR Parse error: syntax error, unexpected T_STRING, expecting ‘)’ in Parse error: syntax error,… Ошибка: Parse error: syntax error, unexpected T_VARIABLE Parse error: syntax error, unexpected ‘isset’ (T_ISSET) Parse error: syntax error, unexpected ‘;’, expecting T_WHILE Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 3 |
-
2
0
Votes2
Posts0
ViewsK
Maybe we should use a common interface and a static class instead of callback.
-
2
0
Votes2
Posts0
ViewsC
Working option:PHP:// Методы
function encrypt($message)
{
// Ключ
$AES_Key256 = ‘28937539283712098445739080393827’;
// Вектор
$AES_IV = ‘8574930392882739’;// Алгоритм шифрования
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, », MCRYPT_MODE_CBC, »);if (mcrypt_generic_init($cipher, $AES_Key256, $AES_IV) != -1)
{
$cipherText = mcrypt_generic($cipher, addpadding($message));
mcrypt_generic_deinit($cipher);
return base64_encode($cipherText);
}}
function addpadding($string, $blocksize = 16)
{
$len = strlen($string);
$pad = $blocksize — ($len % $blocksize);
$string .= str_repeat(chr($pad), $pad);
return $string;
}
C#// Ключ
private const string AES_Key = «28937539283712098445739080393827»;
// Вектор
private const string AES_IV = «8574930392882739»;
// Расшифровывает строку из AES 256 CBC PKCS7 из файла
internal static string AES_Decrypt(string inputStr)
{
byte[] xBuff = null;
using (var aes = new RijndaelManaged())
{
// Настройки
aes.KeySize = 256;
aes.BlockSize = 128;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
aes.Key = Encoding.UTF8.GetBytes(AES_Key);
aes.IV = Encoding.UTF8.GetBytes(AES_IV);using (var ms = new MemoryStream())
{
using (var cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Write))
{
byte[] textArr = Convert.FromBase64String(inputStr);
cs.Write(textArr, 0, textArr.Length);
}
xBuff = ms.ToArray();
}
}return Encoding.UTF8.GetString(xBuff);
}
Article required to understand the principles of AES in PHP: https://www.chilkatsoft.com/p/php_aes.asp -
2
0
Votes2
Posts0
ViewsC
Your question is not entirely clear. ReactJS is a front-end, PHP is a back-and. ReactJS can be tied to a NYBOYBA type of baek-and even if it is Java, Python, Ryby, etc.On the basis of where to keep id, there’s a big choice, from the cue to the localStorage and sessionStorage.There’s the same CacheStorage and IndexedDb. As you understood from the name, they are all used for different purposes.
-
2
0
Votes2
Posts0
ViewsD
Shipping via ♪ is correct, but note that you are already displaying the id ($id = $_GET[‘id’];) URL, what makes this visible id to all. This is a matter of taste, but you should really worry about good practices, SQL Injection, etc. Search for on Google: http://rberaldo.com.br/boas-praticas-programacao-php/ https://pt.stackoverflow.com/questions/9734/como-evitar-sql-injection-em-minha-aplica%C3%A7%C3%A3o-php Success!
-
2
0
Votes2
Posts0
ViewsJSON is not intended for dosing.Translation of lines can be done using a state constant PHP_EOLfile_put_contents(‘data.json’, $new_post.PHP_EOL, FILE_APPEND);
It won’t help. Two records should look like this:[
{«title»:»value1″, «text»:»value2″},
{«title»:»value3″, «text»:»value4″}
]
Although you can, in a simple case, to create a file initially with an open bracket [ and first data recordDo you copy? ‘,’.PHP_EOL.$new_json_rowWhen reading the file, but before decoding, json add at the end ] And then decode.But it looks like a crutch.Without knowing the original challenge, it’s hard to say anything. But perhaps you’d better get a normal SBS. -
2
0
Votes2
Posts0
Viewsmysqli_query($CONNECT, «INSERT INTO ‘users’
VALUES (»,’$_POST[login]’,’$_POST[password]’,’$_POST[email]’,’NOW()'»)
Given the previous answer, I’d say it’s here. ‘users’ taken into skirts when the right thing ismysqli_query($CONNECT, «INSERT INTO users (col1, col2, col3, col4, col5)
VALUES (»,’$_POST[login]’,’$_POST[password]’,’$_POST[email]’,’NOW()'») -
2
0
Votes2
Posts0
ViewsB
Use prepared statments, so your query is vulnerable.Your mistake is probably on query because you’re using an accent on «users» !In any case, use the prepared statments you have an example of the code and the link of the documentation site:
https://www.php.net/manual/en/mysqli.prepare.php Code:if(empty($login) or empty($senha)):
$erros[] = «<li> O campo login/senha precisa ser preenchido </li>»;
else:
$sql = $mysqli->prepare(«SELECT login FROM usuarios WHERE login=»);
$sql->bind_param(«s», $login);$sql->execute();
$resultado = mysqli_query($connect, $sql) or die(mysqli_error($connect)); //mysqli_query($connect, $sql) or die mysql_error();
if(mysqli_num_rows($resultado) > 0):
$senha = md5($senha);
$sql = «SELECT * FROM usuarios WHERE login = ‘$login’ AND senha = ‘$senha'»;
$resultado = mysqli_query($connect, $sql);if(mysqli_num_rows($resultado) == 1):
$dados = mysqli_fetch_array($resultado);
$_SESSION[‘logado’] = true;
$_SESSION[‘id_usuário’] = $dados[‘id’];
header(‘Location: home.php’);
else:
$erros[] = «<li> Usuário e senha incorretos </li>»;
endif;else:
$erros[] = «<li> Usuário inexistente </li>»;
endif; -
2
0
Votes2
Posts0
ViewsC
I recommend using in-memory database or slope as cli, preferably not php. https://www.sqlite.org/inmemorydb.html
-
2
0
Votes2
Posts0
ViewsK
This is a problem in solving class names. The cause of this you yourself said in the question: PHP versions are different in the development and the publishing server.A priori you only have two options: 1) Make your application run in the correct version of PHP — regardless of how this will be done; and 2) Adapt your application to run in version 5.4 of PHP.
-
2
0
Votes2
Posts0
ViewsWhen they have n values in one insert, these need to be separated by comma:insert into [table_name] (column_1, column_2, …)
values (value_1, value_2, …), (value_3, value_4, …)
In your code apparently you want to do this, you even make a substring to remove the comma after the foreach, but you forgot to concatenate the comma at the end of each set of values:'».$linha_bd[‘localizacao’].»‘)»;
Change to:'».$linha_bd[‘localizacao’].»‘),»; -
2
0
Votes2
Posts0
ViewsT
Syntax http://php.net/manual/es/language.types.string.php#language.types.string.syntax.heredoc establishes for the closing label that:It has to be at the beginning of the line.Nothing else is allowed than the closing tag on that line.I mean, can’t be that comment on the same line that the closure:$heredoc = <<<XXX
…
XXX; // Este comentario genera que no se cierre (ERROR) <—-
Corrected:<?php
$html = <<<XXX
<script type=»text/javascript»>
…
</script>
XXX;
//must begin in column 0 or ERR
echo $html; -
2
0
Votes2
Posts0
ViewsHere’s the algorithm:Take the first unsettled top of the count.Nailing https://ru.wikipedia.org/wiki/%D0%9F%D0%BE%D0%B8%D1%81%D0%BA_%D0%B2_%D0%B3%D0%BB%D1%83%D0%B1%D0%B8%D0%BD%D1%83 or https://ru.wikipedia.org/wiki/%D0%9F%D0%BE%D0%B8%D1%81%D0%BA_%D0%B2_%D1%88%D0%B8%D1%80%D0%B8%D0%BD%D1%83 All the peaks achievable from it.Each of the peaks visited (including the original) is marked as (please for tautology) visited. If not all the tops were visited, I goto 1.For this algorithm, it will be convenient to establish a separate set of visits to the top. To mark the peaks in it as visited by the best number of spectaculars to the order number of the «storm» to which the top belongs. The number «sorrow» will increase by 1 in c. 1. It will also be convenient to track the completion point of the algorithm, as soon as all the peaks in it are marked as visited, the algorithm has finished its work.
-
2
0
Votes2
Posts0
ViewsIf you have the possibility of installing on your server, https://code.google.com/p/tesseract-ocr/ is an opensource OCR engine made available by Google. She owns a https://github.com/thiagoalessio/tesseract-ocr-for-php .Otherwise, you can try webservices as https://developers.google.com/google-apps/documents-list/#uploading_documents_using_optical_character_recognition_ocr .
-
2
0
Votes2
Posts0
ViewsIs there any confusion?exec($converter.» -i $folder» .$ffile.» $atata $folder» .$tt.«_». $ffile.».mp4 1> ffmpeg/block.txt 2>&1 &»);
$converter = «/usr/bin/ffmpeg»; -
2
0
Votes2
Posts0
ViewsO
One problem I’ve detected is that you’re concatenating the instruction wrong insert.Try to arrange for the following way$sqlCadastraTarefa=»Insert into Tarefas (nome_TAREFA, dataInicio_TAREFA, dataFim_TAREFA, «;
$sqlCadastraTarefa.=»descricao_TAREFA, prioridade_TAREFA, cor_TAREFA)»;
The way you concatenated would be getting as follows the instruction Insert into Tarefas (nome_TAREFA, dataInicio_TAREFA, dataFim_TAREFA, )(descricao_TAREFA, prioridade_TAREFA, cor_TAREFA)
Staying One ,) ( between the columns.The way I put it wouldInsert into Tarefas (nome_TAREFA, dataInicio_TAREFA, dataFim_TAREFA, descricao_TAREFA, prioridade_TAREFA, cor_TAREFA)
Различные части языка PHP внутренне представлены токенами.
Фрагмент кода, содержащий недопустимую последовательность токенов, может привести к таким ошибкам, как Parse error: syntax error, unexpected token "==", expecting "(" in script.php on line 10."
,
где токен ==
внутренне представлен как T_IS_EQUAL
.
В следующей таблице перечислены все токены. Они также доступны как константы PHP.
Замечание:
Использование T_* константЗначения T_* констант автоматически генерируются на основе базовой инфраструктуры синтаксического анализатора PHP.
Это означает, что конкретное значение метки может изменяться
между двумя версиями PHP.
Это означает, что ваш код никогда не должен напрямую полагаться
на исходные значения T_*, взятые из версии PHP X.Y.Z,
чтобы обеспечить некоторую совместимость между несколькими версиями PHP.Чтобы использовать T_* константы в нескольких версиях PHP, неопределённые константы
могут быть определены пользователем (с использованием больших чисел, таких как10000
)
с соответствующей стратегией, которая будет работать как с версиями PHP, так и со значениями T_*.
<?php
// До PHP 7.4.0 значение T_FN не определено.
defined('T_FN') || define('T_FN', 10001);
Метка | Синтаксис | Ссылка |
---|---|---|
T_ABSTRACT |
abstract | Абстрактные классы |
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG |
& | Объявление типов (доступно, начиная с PHP 8.1.0) |
T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG |
& | Объявление типов (доступно, начиная с PHP 8.1.0) |
T_AND_EQUAL |
&= | операторы присваивания |
T_ARRAY |
array() | array(), синтаксис массива |
T_ARRAY_CAST |
(array) | приведение типа |
T_AS |
as | foreach |
T_ATTRIBUTE |
#[ | attributes (доступно с PHP 8.0.0) |
T_BAD_CHARACTER |
все, что ниже ASCII 32 исключая t (0x09), n (0x0a) и r (0x0d) (доступно с PHP 7.4.0) |
|
T_BOOLEAN_AND |
&& | логические операторы |
T_BOOLEAN_OR |
|| | логические операторы |
T_BOOL_CAST |
(bool) или (boolean) | приведение типа |
T_BREAK |
break | break |
T_CALLABLE |
callable | callable |
T_CASE |
case | switch |
T_CATCH |
catch | Исключения |
T_CLASS |
class | классы и объекты |
T_CLASS_C |
__CLASS__ | магические константы |
T_CLONE |
clone | классы и объекты |
T_CLOSE_TAG |
?> или %> | PHP-код внутри HTML |
T_COALESCE |
?? | операторы сравнения |
T_COALESCE_EQUAL |
??= |
операторы присваивания (доступно с PHP 7.4.0) |
T_COMMENT |
// или #, и /* */ | комментарии |
T_CONCAT_EQUAL |
.= | операторы присваивания |
T_CONST |
const | константы класса |
T_CONSTANT_ENCAPSED_STRING |
«foo» или ‘bar’ | строковой синтаксис |
T_CONTINUE |
continue | continue |
T_CURLY_OPEN |
{$ | переменные внутри строки |
T_DEC |
— | операторы инкрементадекремента |
T_DECLARE |
declare | declare |
T_DEFAULT |
default | switch |
T_DIR |
__DIR__ | магические константы |
T_DIV_EQUAL |
/= | операторы присваивания |
T_DNUMBER |
0.12 и т.д. | числа с плавающей точкой |
T_DO |
do | do..while |
T_DOC_COMMENT |
/** */ | PHPDoc-комментарии |
T_DOLLAR_OPEN_CURLY_BRACES |
${ | переменная внутри строки |
T_DOUBLE_ARROW |
=> | синтаксис массивов |
T_DOUBLE_CAST |
(real), (double) или (float) | приведение типов |
T_DOUBLE_COLON |
:: | смотрите ниже T_PAAMAYIM_NEKUDOTAYIM |
T_ECHO |
echo | echo |
T_ELLIPSIS |
… | аргументы функции |
T_ELSE |
else | else |
T_ELSEIF |
elseif | elseif |
T_EMPTY |
empty | empty() |
T_ENCAPSED_AND_WHITESPACE |
» $a» | константная часть строки с переменными |
T_ENDDECLARE |
enddeclare | declare, альтернативный синтаксис |
T_ENDFOR |
endfor | for, альтернативный синтаксис |
T_ENDFOREACH |
endforeach | foreach, альтернативный синтаксис |
T_ENDIF |
endif | if, альтернативный синтаксис |
T_ENDSWITCH |
endswitch | switch, альтернативный синтаксис |
T_ENDWHILE |
endwhile | while, альтернативный синтаксис |
T_ENUM |
enum | Перечисления (доступно, начиная с PHP 8.1.0) |
T_END_HEREDOC |
синтаксис heredoc | |
T_EVAL |
eval() | eval() |
T_EXIT |
exit или die | exit(), die() |
T_EXTENDS |
extends | extends, классы и объекты |
T_FILE |
__FILE__ | магические константы |
T_FINAL |
final | Ключевое слово final |
T_FINALLY |
finally | Исключения |
T_FN |
fn |
стрелочные функции (доступно с PHP 7.4.0) |
T_FOR |
for | for |
T_FOREACH |
foreach | foreach |
T_FUNCTION |
function | функции |
T_FUNC_C |
__FUNCTION__ | магические константы |
T_GLOBAL |
global | область видимости переменной |
T_GOTO |
goto | goto |
T_HALT_COMPILER |
__halt_compiler() | __halt_compiler |
T_IF |
if | if |
T_IMPLEMENTS |
implements | Интерфейсы объектов |
T_INC |
++ | операторы инкрементадекремента |
T_INCLUDE |
include() | include |
T_INCLUDE_ONCE |
include_once() | include_once |
T_INLINE_HTML |
текст вне PHP | |
T_INSTANCEOF |
instanceof | операторы типа |
T_INSTEADOF |
insteadof | Трейты |
T_INTERFACE |
interface | Интерфейсы объектов |
T_INT_CAST |
(int) или (integer) | приведение типов |
T_ISSET |
isset() | isset() |
T_IS_EQUAL |
== | операторы сравнения |
T_IS_GREATER_OR_EQUAL |
>= | операторы сравнения |
T_IS_IDENTICAL |
=== | операторы сравнения |
T_IS_NOT_EQUAL |
!= или <> | операторы сравнения |
T_IS_NOT_IDENTICAL |
!== | операторы сравнения |
T_IS_SMALLER_OR_EQUAL |
<= | операторы сравнения |
T_LINE |
__LINE__ | магические константы |
T_LIST |
list() | list() |
T_LNUMBER |
123, 012, 0x1ac и т.д. | целые числа |
T_LOGICAL_AND |
and | логические операторы |
T_LOGICAL_OR |
or | логические операторы |
T_LOGICAL_XOR |
xor | логические операторы |
T_MATCH |
match | match (доступно с PHP 8.0.0) |
T_METHOD_C |
__METHOD__ | магические константы |
T_MINUS_EQUAL |
-= | операторы присваивания |
T_MOD_EQUAL |
%= | операторы присваивания |
T_MUL_EQUAL |
*= | операторы присваивания |
T_NAMESPACE |
namespace | пространства имён |
T_NAME_FULLY_QUALIFIED |
AppNamespace | пространства имён (доступно, начиная с PHP 8.0.0) |
T_NAME_QUALIFIED |
AppNamespace | пространства имён (доступно, начиная с PHP 8.0.0) |
T_NAME_RELATIVE |
namespaceNamespace | пространства имён (доступно, начиная с PHP 8.0.0) |
T_NEW |
new | классы и объекты |
T_NS_C |
__NAMESPACE__ | пространства имён |
T_NS_SEPARATOR |
пространства имён | |
T_NUM_STRING |
«$a[0]» | цифровой индекс массива внутри строки |
T_OBJECT_CAST |
(object) | приведение типов |
T_OBJECT_OPERATOR |
-> | классы и объекты |
T_NULLSAFE_OBJECT_OPERATOR |
?-> | классы и объекты |
T_OPEN_TAG |
<?php, <? или <% | PHP-код внутри HTML |
T_OPEN_TAG_WITH_ECHO |
<?= или <%= | PHP-код внутри HTML |
T_OR_EQUAL |
|= | операторы присваивания |
T_PAAMAYIM_NEKUDOTAYIM |
:: | ::. Также определяется какT_DOUBLE_COLON . |
T_PLUS_EQUAL |
+= | операторы присваивания |
T_POW |
** | арифметические операторы |
T_POW_EQUAL |
**= | операторы присваивания |
T_PRINT |
print() | |
T_PRIVATE |
private | классы и объекты |
T_PROTECTED |
protected | классы и объекты |
T_PUBLIC |
public | классы и объекты |
T_READONLY |
readonly | классы и объекты (доступно, начиная с PHP 8.1.0) |
T_REQUIRE |
require() | require |
T_REQUIRE_ONCE |
require_once() | require_once |
T_RETURN |
return | возвращаемые значения |
T_SL |
<< | побитовые операторы |
T_SL_EQUAL |
<<= | операторы присваивания |
T_SPACESHIP |
<=> | Операторы сравнения |
T_SR |
>> | побитовые операторы |
T_SR_EQUAL |
>>= | операторы присваивания |
T_START_HEREDOC |
<<< | синтаксис heredoc |
T_STATIC |
static | область видимости переменной |
T_STRING |
parent, self и т.п.. |
идентификаторы, например, ключевые слова вроде parent и self ,сюда подходят также имена функций, классов и некоторые другие. Смотрите также T_CONSTANT_ENCAPSED_STRING
|
T_STRING_CAST |
(string) | приведение типов |
T_STRING_VARNAME |
«${a | переменные внутри строки |
T_SWITCH |
switch | switch |
T_THROW |
throw | Исключения |
T_TRAIT |
trait | Трейты |
T_TRAIT_C |
__TRAIT__ | __TRAIT__ |
T_TRY |
try | Исключения |
T_UNSET |
unset() | unset() |
T_UNSET_CAST |
(unset) | приведение типов |
T_USE |
use | пространства имён |
T_VAR |
var | классы и объекты |
T_VARIABLE |
$foo | переменные |
T_WHILE |
while | while, do..while |
T_WHITESPACE |
t rn | |
T_XOR_EQUAL |
^= | операторы присваивания |
T_YIELD |
yield | генераторы |
T_YIELD_FROM |
yield from | generators |
Смотрите также token_name().
nathan at unfinitydesign dot com ¶
14 years ago
T_ENCAPSED_AND_WHITESPACE is whitespace which intersects a group of tokens. For example, an "unexpected T_ENCAPSED_AND_WHITESPACE" error is produced by the following code:
<?php
$main_output_world = 'snakes!';
echo('There are' 10 $main_output_world);
?>
Note the missing concatenation operator between the two strings leads to the whitespace error that is so named above. The concatenation operator instructs PHP to ignore the whitespace between the two code tokens (the so named "encapsed" data"), rather than parse it as a token itself.
The correct code would be:
<?php
$main_output_world = 'snakes!';
echo('There are' . 10 . $main_output_world);
?>
Note the addition of the concatenation operator between each token.
fgm at osinet dot fr ¶
14 years ago
T_ENCAPSED_AND_WHITESPACED is returned when parsing strings with evaluated content, like "some $value" or this example from the Strings reference page:
<?php
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': x41
EOT;
?>
This last example is tokenized as:
T_ECHO
echo
T_WHITESPACE
%20 (a space character)
T_START_HEREDOC
<<
T_ENCAPSED_AND_WHITESPACE
My name is "
T_VARIABLE
$name
T_ENCAPSED_AND_WHITESPACE
". I am printing some
T_VARIABLE
$foo
T_OBJECT_OPERATOR
->
T_STRING
foo
T_ENCAPSED_AND_WHITESPACE
. Now, I am printing some
T_CURLY_OPEN
{
T_VARIABLE
$foo
T_OBJECT_OPERATOR
->
T_STRING
bar
(terminal)
[
T_LNUMBER
1
(terminal)
]
(terminal)
}
T_ENCAPSED_AND_WHITESPACE
. This should print a capital 'A': x41
T_END_HEREDOC
EOT
(terminal)
;