这是我的php文件中的一个函数,用于满足我的android应用程序的请求。function checkin($DB, $TechID, $ClientID, $SiteID){ $dbConnection = mysql_connect($DB['server'], $DB['loginName'], $DB['password']); if(!$dbConnection){ die('Error! ' . mysql_error()); } mysql_select_db($DB['database'], $dbConnection); $file2 = "C:/wamp/www/file2.txt"; $data2 = "ClientID:".$ClientID." TechID:".$TechID." SiteID:".$SiteID; file_put_contents($file2, $data2); $result1 = mysql_query("SELECT COUNT(*) FROM Log") or die('Error! ' . mysql_error()); $query = "SELECT `Type` FROM `Log` WHERE `TechID` = '".$TechID."' ORDER BY LogTime DESC LIMIT 1"; $file5 = "C:/wamp/www/file5.txt"; file_put_contents($file5, $query); $result2 = mysql_query($query) or die('Error! ' . mysql_error()); while($row1 = mysql_fetch_array($result1)){ $count = $row1['COUNT(*)']; $file3 = "C:/wamp/www/file3.txt"; $data3 = "ClientID:".$ClientID." TechID:".$TechID." SiteID:".$SiteID." Count:".$count; file_put_contents($file3, $data3); while($row2 = mysql_fetch_array($result2)){ $file4 = "C:/wamp/www/file4.txt"; $data3 = "ClientID:".$ClientID." TechID:".$TechID." SiteID:".$SiteID." Count:".$count; file_put_contents($file4, $data3); /*if($row2['Type']!="Checkin"){ $count = $count+1; $Time = date('Y/m/d H:i'); mysql_query("INSERT INTO Log (LogID, TechID, ClientID, SiteID, LogTime, Type) VALUES (".$count.", ".$TechID.", ".$ClientID.", ".$SiteID.", ".$Time.", Checkin)"); }else{ $query2 = "SELECT TechEmail FROM Tech WHERE TechID=".$TechID; $result3 = mysql_query($query2) or die('Error! ' . mysql_error()); } }*/ } }}您会看到我已经隐藏了一些代码,因为我正在调试它,所以创建了一些文件只是为了查看代码的哪一部分无法执行。我发现程序无法进入应创建file4的区域。我已经发现问题可能出在$ query上,当它执行时,mysql会响应“未知表状态:TABLE_TYPE”,这我不明白为什么。
3 回答
慕神8447489
TA贡献1780条经验 获得超1个赞
简单的答案应该是:
mysql_query("INSERT INTO Log (LogID, TechID, ClientID, SiteID, LogTime, Type)
VALUES (".$count.", ".$TechID.", ".$ClientID.", ".$SiteID.", ".$Time.", Checkin)");
从$ vars中删除引号。或单引号。同时删除点。喜欢:
mysql_query("INSERT INTO Log (LogID, TechID, ClientID, SiteID, LogTime, Type)
VALUES ('$count', '$TechID', '$ClientID', '$SiteID', '$Time', Checkin)");
添加回答
举报
0/150
提交
取消