2011-03-17 58 views
1

谁能给我解释一下为什么我得到这个错误:意外';'在脚本..但是当我删除T_STRING错误

Parse error: syntax error, unexpected ';' in C:\wamp\www\scripts_for_profile\follow.php on line 10 

当我尝试运行此脚本:

<?php 
include("/user_sytem_scripts/session.php"); 
include("/scripts/connect.php"); 

/* Gets folllowing username */ 
$following = trim($_GET['user']); 
if(!$req_user || strlen($following) == 0 || 
    !preg_match("^([0-9a-z])+$^", $following) || 
/* Gets follower username */ 
$query = "INSERT INTO follow (follower_username, following_username, time) VALUES ('$session->username', '$following' now())"; mysql_query($query) or die(mysql_error()); 
?> 

我真的很困惑,谁能帮忙?因为如果我删除了;我得到了T_STRING错误。

+0

我认为你应该在早晨 – 2011-03-17 23:16:17

+0

@Imran奥马尔Bukhsh你怎么知道这是不是早上user663049休息和代码? – 2011-03-17 23:27:43

+0

因为他似乎真的很困,不能发现失踪的')' – 2011-03-17 23:31:08

回答

3

您似乎已将您的if声明的结尾留下。

!preg_match("^([0-9a-z])+$^", $following) || 

...“与此正则表达式不匹配”​​...什么?

它解决了串到$query变量作为下一个“或”的分配,然后当它击中;因为它是期待一个)倒了。

1
if(!$req_user || strlen($following) == 0 || 
    !preg_match("^([0-9a-z])+$^", $following) || //here missing condition and){ 
// or extra || 
/* Gets follower username */ 
0

你的条件不被关闭:

if(!$req_user || strlen($following) == 0 || 
    !preg_match("^([0-9a-z])+$^", $following)) 
相关问题