Home > Article > Backend Development > sql语法错误??
Query failed:SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROMmembers WHERE id = 0' at line 1
<?phprequire_once("common.inc.php");require_once("config.php");require_once("Member.class.php");require_once("LogEntry.class.php");$memberId = isset($GET_["memberId"])?(int)$_GET("memberId"):0;if(!$memberId = Member::getMember($memberId)){ displayPageHeader("Error"); echo"<div> Member not found.</div>"; displayPageFooter(); exit;}$logEntries = LogEntry::getLogEntries($memberId);displayPageHeader("View member: ".$member->getValueEncoded("firstName")." ".$member->getValueEncoded("lastName"));?> <dl style="width: 30em;"> <dt>Username</dt> <dd><?php echo $member->getValueEncoded("username")?></dd> <dt>First name</dt> <dd><?php echo $member->getValueEncoded("firstname")?></dd> <dt>Last name</dt> <dd><?php echo $member->getValueEncoded("lastname")?></dd> <dt>Joined on</dt> <dd><?php echo $member->getValueEncoded("joinData")?></dd> <dt>Gender</dt> <dd><?php echo $member->getGenderString()?></dd> <dt>Favorite genre</dt> <dd><?php echo $member->getFavoriteGenreString()?></dd> <dt>Email address</dt> <dd><?php echo $member->getValueEncoded("emailAddress")?></dd> <dt>Other interests</dt> <dd><?php echo $member->getValueEncoded("otherInterests")?></dd> </dl> <h2>Access log</h2> <table cellspacing="0" style="width:30em;border:1px solid #666;"> <tr> <th>Web page</th> <th>Number of visits</th> <th>Last visit</th> </tr><?php$rowCount = 0;foreach($logEntries as $logEntry){ $rowCount++;?> <tr><?php if($rowCount%2 == 0) echo'class="alt"'?>> <td><?php echo $logEntry->getValueEncoded("pageUrl")?></td> <td><?php echo $logEntry->getValueEncoded("numVisits")?></td> <td><?php echo $logEntry->getValueEncoded("lastAccess")?></td> </tr><?php }?> </table> <div style="width:30em;margin-top:20px;text-align:center;"> <a href="javascript:history.go(-1)">Back</a> </div> <?phpdisplayPageFooter();?>
'FROMmembers
FROM members xxxxx
Query failed:SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' FROMmembers WHERE id = 0' at line 1
select 指令的基本格式是
SELECT 字段列表 FROM 表名
你把 FROM 和 members 粘在一起,SQL 指令解析器如何能认得他们?
'FROMmembers
FROM members xxxxx
啥意思啊
就是让你分开来写,不然FROM这个关键字识别不出来的。
'FROMmembers
FROM members xxxxx
啥意思啊
这又是什么问题啊
请确定是否存在Member数据表。