在第一页上,我有这个
// start memcached
$m = new Memcached();
$m->addServer('localhost', 11211);
$key = 'test_' . $ID_ref;
$test_data = array(....);
$m->set($key, $test_data);
// end memcached
好的,到目前为止。在下一页,
// start memcached
$m = new Memcached();
$m->connect('localhost', 11211);
var_dump($m->get($key));
// end memcached
发生以下错误:
调用未定义的方法Memcached :: connect()
phpinfo()
显示memcached是由webhost安装的,似乎是memcached does not support connect()
我应该使用什么?
答案 0 :(得分:2)
而不是
<head>
<style>
popup {
background-color: #eee;
display: none;
width: 300px;
height: 400px;
margin: 0 auto;
border-style: solid;
border-width: 2px;
}
</style>
</head>
<body onload="start()">
<div>
<table id='table'>
</table>
</div>
<popup id='popup'>
<div id="contactdiv">
<form class="form" action="#" id="contact">
<img src="images/button_cancel.png" class="img" id="cancel" />
<h3>Contact Form</h3>
<h3 id='the-key'>Key: </h3>
<hr/>
<br/>
<label>Name: <span>*</span>
</label>
<br/>
<input type="text" id="name" placeholder="Name" />
<br/>
<br/>
<label>Email: <span>*</span>
</label>
<br/>
<input type="text" id="email" placeholder="Email" />
<br/>
<br/>
<label>Contact No: <span>*</span>
</label>
<br/>
<input type="text" id="contactno" placeholder="10 digit Mobile no." />
<br/>
<br/>
<label>Message:</label>
<br/>
<textarea id="message" placeholder="Message......."></textarea>
<br/>
<br/>
<input type="button" id="send" value="Send" />
<input type="button" id="cancel" value="Cancel" />
<br/>
</form>
</div>
</popup>
</body>
<script>
function start() {
var data = {
'result': [{
'a': 'a',
'b': 'b',
'c': 'c',
'INIT1': 3,
'INIT2': 5,
'RUNNING': 'YES'
}, {
'a': 'a',
'b': 'b',
'c': 'c',
'INIT1': 3,
'INIT2': 5,
'RUNNING': 'NO'
}]
};
extract_results(data);
}
function extract_results(jsonDataRaw) {
var jsonResultSect = jsonDataRaw['result'];
var retTable = "";
var retText = "ret text <br/>";
for (key in jsonResultSect) {
var myJ = jsonResultSect[key]
var a = myJ['a']
var b = myJ['b']
var c = myJ['c']
var init = myJ['INIT1'] + myJ['INIT2']
var r = myJ['RUNNING']
table.innerHTML += "<tr><td><td>" + key + "</td><td>" + a + "</td><td>" + b + "</td><td>" + c + "</td><td>" + init + "</td><td>" + r + "</td><td><button onclick='openDialogue(" + key + ")'>Show Key</button></td></tr>"
}
return retTable
}
function openDialogue(key) {
document.getElementById('popup').style.display = 'block';
document.getElementById('the-key').innerHTML = 'Key: ' + key;
}
</script>
简单地重复使用
$m = new Memcached();
$m->connect('localhost', 11211);
$m = new Memcached();
$m->addServer('localhost', 11211);
是一个 Memcache 方法而不是 Memcached