Php 语法错误,意外的T_AS,应为“')”
我已经检查和重试了很多东西,我只是不知道什么是错的Php 语法错误,意外的T_AS,应为“')”,php,Php,我已经检查和重试了很多东西,我只是不知道什么是错的 <?php include('database.class.php'); $sql = new Database(NULL); $ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true); $dump = array(); foreach ($ids as $index as $id) $dump[] =
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index as $id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>
应该是:
foreach ($ids as $index as $id)
这是错误的:
foreach ($ids as $index => $id)
它的语法不正确,而且您没有在任何地方使用$index。只要用这个:
foreach ($ids as $index as $id)
请参阅您认为每一个都是错误的。像这样试试。键值对用于表示此运算符=>
正确代码
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index=>$id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>
你的问题在哪里?我现在得到的是为foreach提供的无效参数。如果你使用var_dump$ids,很可能它是一个布尔值false,而不是一个数组。看起来您的sql格式不正确。它应该类似于从表中选择id。
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index=>$id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index => $id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>