我期待这是一个我忽略的基本语法错误,但我无法弄清楚.
在PHP脚本中,我不断收到以下错误.
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in [path]/scripts/users/database_connection.php on line 4
Run Code Online (Sandbox Code Playgroud)
当我使用a调用连接到数据库的脚本时会发生这种情况include_once()
.我将我的脚本删除到最基本的代码(留下其他代码所需的代码),它仍然在调用此错误.
<?php
class UserDatabaseConnection
{
$connection = sqlite_open("[path]/data/users.sqlite", 0666);
public function lookupUser($username)
{
// rest of my code...
}
}
$udb = new UserDatabaseConnection;
?>
Run Code Online (Sandbox Code Playgroud)
我已经挣扎了一段时间,只是想知道是否有其他人可以发现我出错的地方.
我正在开发一个 Node.js 插件,它需要用 C++ 包装C 库中的对象,以便可以从客户端 JavaScript(用 CoffeeScript 编写)访问它们。
C++ 模块可以编译,但是当我尝试通过 Node.js JavaScript 运行它时,无法调用 C 库,并symbol lookup error
出现调试问题。
错误如下:
node: symbol lookup error: /var/lib/cloud9/ledscape-wrapper/wrapper/build/Release/wrapper.node: undefined symbol: ledscape_init
wrapper.node
是编译后的包,ledscape_init
是我尝试调用的库中的函数。
我尝试跟踪代码并在多个文件中找到相关片段。我删除了我认为无关的台词。
# "AllFade.coffee"
@ledscape = require "./ledscape.js"
@frames[1] = @ledscape.LedscapeInit()
# "Ledscape.coffee"
wrapper = require "./build/Release/wrapper"
module.exports = wrapper
Run Code Online (Sandbox Code Playgroud)
包装器.cc
extern "C" {
#include <ledscape.h>
}
#include <node.h>
#include <v8.h>
#include <node_object_wrap.h>
#include "LedscapeWrapper.h"
Handle<Value> LedscapeInit(const Arguments& args) {
HandleScope scope;
return scope.Close(LedscapeWrapper::NewInstance(args));
}
void InitAll(Handle<Object> …
Run Code Online (Sandbox Code Playgroud) 所以我一直在尝试调试我的 jQuery.post() 调用,并且得到了一些奇怪的响应。我被困在下一步该做什么,如果有人有任何建议,我将非常感激。
<script type="text/javascript">
var debugresp;
var debugpost;
$("#scan .scanSide button.startScan").click(function() {
// ...
console.log("Scanning...");
debugpost = $.post(
"scan/scan.php",
{
"side": side
},
function(response) {
console.log(response);
/*...*/
},
"xml"
);
console.log("Sent data...");
});
<script>
Run Code Online (Sandbox Code Playgroud)
外部的两个console.log()
调用$.post
工作正常,页面200 OK
在“网络”选项卡(调试工具/Chrome)下返回有效数据,但内部console.log(response)
从未触发。
如果您注意到的话,我保存了来自 的退货$.post
。
// JavaScript console, while page hasn't returned yet
debugpost.state()
// > "pending"
// After the page returns, and console.log(response) hasn't been called
debugpost.state()
// > "rejected"
Run Code Online (Sandbox Code Playgroud)
我从未尝试过处理 中的问题jQuery.post
,但我不希望从jqXHR …
我遇到了PHP会话变量的问题:我尝试设置变量,即使在同一个文件中也不能读取它们,更不用说另一个文件了.
很抱歉,如果之前已经问过这个问题,但我找不到任何不说"确保你session_start()
在文件开头就有"的问题.
文件的第1,2和3行:
<?php
ini_set('session.save_path','/home/[username]/session_data'); // Just in case, points to a correct directory
session_start();
Run Code Online (Sandbox Code Playgroud)
之后,在用户名验证和登录之后,变量被设置,代码会尝试echo
输出:
$_SESSION['login'] == "true";
$_SESSION['username'] == $username;
$_SESSION['password'] == sha1($password);
//header("Location: [admin page hidden]"); // Code would normally redirect to admin page (commented out for debugging), and exit
//exit;
echo "Username: ".$username."<br />"; // The following 4 lines try to print out the data
echo "Password: ".$password."<br />";
echo "Secure Password: ".sha1($password)."<br />";
echo "Session Username: ".$_SESSION['username']."<br />";
Run Code Online (Sandbox Code Playgroud)
输出是:
Username: root …
Run Code Online (Sandbox Code Playgroud) 我正在使用AJAX系统提交表单,但我甚至无法加载我的JavaScript,Firebug报告如下.
missing ) after argument list
else if( httpRequest.responseText == 'already logged in' )\n
Run Code Online (Sandbox Code Playgroud)
我在互联网上搜索了一下,但我发现的只是引用错误.(例子,另一个例子).我没有任何错误引用,所以我真的不知道发生了什么.我的更多代码如下.
(删除了一些不相关的函数调用以删除加载消息.)
if(httpRequest.responseText != "failure") // Works fine!
{
document.getElementById("result").innerHTML = "[Success message]";
setTimeout("2000", function(){ window.location.assign("[link to page]");
}
else if(httpRequest.responseText == 'already logged in') // Similar to above, but fails
{
document.getElementById("result").innerHTML = "[error message]";
}
else
{
document.getElementById("result").innerHTML = "[error message]";
}
Run Code Online (Sandbox Code Playgroud)
可能有人知道为什么会出现这个错误?
(对于更多成员,可能有助于概述导致此错误的原因,这将允许此页面与其他代码一起使用)
javascript ×3
php ×3
ajax ×2
c ×1
c++ ×1
coffeescript ×1
firebug ×1
jquery ×1
jqxhr ×1
node.js ×1
random ×1
session ×1
sqlite ×1
syntax-error ×1