当前位置:编程学习 > php >>

php提示错误:Parse error: syntax error, unexpected T_FOR, expecting ',' or ';' in E:\search.php

<?php $item=$_POST['item']; $content=$_POST['content']; $content=trim($content); if(!$item||!$content) { echo '请选择一个搜索项并填写要搜索的内容'; exit; } if(!get_magic_quotes_gpc()) { $content=addslashes($content); } $db=@new mysqli("localhost","root","qihui668","test","3308"); if(mysqli_connect_error()){ echo "数据库连接失败!<br>\n"; echo mysqli_connect_error(); exit; } if($item==1) $field='f_name'; if($item==2) $field='f_email'; else{ echo '搜索项不被支持!'; exit; } $sql="select * from t_employee where $field like '%$content%'"; $rs = $db->query($sql); $rsNum = $rs->num_rows; echo "<p>本次搜索共找到<b> $rsNum </b>条记录。</p>" for ($i = 0; $i < $rsNum; $i++){ /////////////////////////////////////此处出错了 $row= $rs->fetch_assoc(); echo '----------------------------------------------<br/>'; echo '<b> 姓名: </b>'.htmlspecialchars(stripslashes($row['f_name'])).'<br/>'; echo '<b> 性别: </b>'.($row['f_gender']!=0?'男':'女').'<br/>'; $education_str=''; switch($row['f_education']){ case 1: $education_str='博士';break; case 2: $education_str='硕士';break; case 3: $education_str='本科';break; case 4: $education_str='大专';break; case 5: $education_str='其他';break; } echo '<b> 学历: </b>'.$education_str.'<br>'; list($year,$month,$day,$hour,$min,$sec)=split('[:-]',$row['f_borntime']); echo '<b> 出生日期: </b>'."{$year}-{$month}-{$day}".'<br/>'; echo '<b> email: </b>'.htmlspecialchars(stripslashes($row['f_email'])).'<br/>'; echo '<b> 电话: </b>'.htmlspecialchars(stripslashes($row['f_phone'])).'<br/>'; echo '----------------------------------------------<br/><br/>'; } $rs->free(); $db->close(); ?>
答案:问题很明显啊,你要好好看错误提示呀。
echo "<p>本次搜索共找到<b> $rsNum </b>条记录。</p>"
后面少了个结束标记 ,加个分号就好了啊。

expecting ',' or ';'   => 这都提示你了呀。
其他:echo "<p>本次搜索共找到<b> $rsNum </b>条记录。</p>"
for ($i = 0; $i < $rsNum; $i++){    /////////////////////////////////////此处出错了
看上一行,没有以分号结束呀 你找到提示错误的行。少写了个分好结束。,或是单双引号的问题、 

上一个:开发PHP网站遇到的困难!!!
下一个:php源码没有数据库?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,