我正在按照本教程在Google云上设置Wordpress网站:https: //googlecloudplatform.github.io/appengine-php-wordpress-starter-project/
现在我正在尝试在我的mac上安装MySQL服务器.我在这里下载了Mac OS X 10.9(x86,64位)压缩TAR存档:http://dev.mysql.com/downloads/mysql/
正如教程所说,我在终端中命令以下行:
/Users/myuser/Downloads/mysql-5.6.24-osx10.9-x86_64/bin/mysql/mysql -u root -p mypassword
Run Code Online (Sandbox Code Playgroud)
首先,终端要求输入密码,当我输入此密码时,会发生以下错误:
ERROR 2002(HY000):无法通过套接字'/tmp/mysql.sock'连接到本地MySQL服务器(2)
我已经在本教程的手上安装了phpMyAdmin:https: //gist.github.com/suvozit/8998731 并将我的RDS实例作为主机连接到/var/www/html/phpmyadmin/config.inc.php文件中.
现在,当我访问example.com/phpmyadmin/index.php时出现以下错误:
缺少mbstring扩展名.请检查您的PHP配置.
所以我在互联网上搜索了这个错误,人们带来了以下解决方案,我尝试过:
安装php-mbstring扩展:
yum install php-mbstring
Run Code Online (Sandbox Code Playgroud)
当我输入此命令时,过程开始,但返回以下行:
-> Processing Conflict: php55-common-5.5.24-1.100.amzn1.x86_64 php-common <5.5.24-1.100.amzn1 conflict
-> Processing Conflict: php55-mbstring-5.5.24-1.100.amzn1.x86_64 php-mbstring <5.5.24-1.100.amzn1 conflict
-> Processing Conflict: php56-common-5.6.8-1.111.amzn1.x86_64 php-common <5.5.22-1.98 conflict
-> Ready to resolve dependencies
Error: php55-mbstring conflicts with php-mbstring 5.3.29-1.8.amzn1.x86_64
Error: php56-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64
Error: php55-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64
You could try using --skip-broken to work around the problem
You could try: rpm -Va --nofiles --nodigest
Run Code Online (Sandbox Code Playgroud)
$ php -v返回:
PHP 5.6.8 (cli) …Run Code Online (Sandbox Code Playgroud) 我正在一个网站上工作,我在1页上有2个表格.我使用1个PHP脚本来检查表单.但如果我在页面上提交我的第二个表格,我的网站会提交第一个表格.如何查看提交的表格?
<!--// Form 1-->
<form method="post">
<input type="text" name="test">
<input type="submit" name="submit">
<input type="hidden" name="page_form" value="1">
</form>
<!--// Form 2-->
<form method="post">
<input type="text" name="test">
<input type="submit" name="submit">
<input type="hidden" name="page_form" value="2">
</form>
Run Code Online (Sandbox Code Playgroud)
PHP:
if(isset($_POST['submit'])) {
$forms = array(1, 2);
foreach($forms as $form) {
if($_POST['page_form'] == $form) {
// All my form validations which are for every form the same.
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从加载Google网络字体导致的Google Pagespeed洞察中删除"脚本作为渲染阻止文件"错误.互联网告诉我使用Web Font Loader加载字体异步.我在页脚中放置了下面的一段javascript,字体加载得很好,但我的pagespeed洞察结果中仍然出现了渲染阻塞错误.
注意:字体渲染阻止错误仅在移动测试中显示,而不是在桌面上显示.
<script>
WebFontConfig = {
google: {
families: ['Archivo Narrow:300,400,700']
}
};
(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async = true;
s.parentNode.insertBefore(wf, s);
})(document);
</script>
Run Code Online (Sandbox Code Playgroud)
编辑:
尝试在关闭body标记之前添加脚本仍会导致渲染阻止文件错误:
<script>
WebFontConfig = {
google: {
families: ['Archivo Narrow:300,400,700']
}
};
(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async = true;
document.body.appendChild(wf);
})(document);
</script>
Run Code Online (Sandbox Code Playgroud)
使用这段jQuery,我检查一些字段是否匹配或不为空,但我收到此错误.
未捕获的TypeError:无法读取未定义的属性"匹配"
谁能告诉我这里做错了什么?
if ( width.match( /^\d+$/ ) && height.match( /^\d+$/ ) && type.length > 0 && color.length > 0 ) {
Run Code Online (Sandbox Code Playgroud)
这是完整的代码:
if( $( "#config" ) ) {
$( 'input, select' ).on( 'change', function(){
var width = $( "#config-steps #width" ).val();
var height = $( "#config-steps #height" ).val();
var type = $( "#config-steps #type" ).val();
var color = $( "#config-steps #selected-color" ).val();
if ( width.match( /^\d+$/ ) && height.match( /^\d+$/ ) && type.length > 0 && color.length > 0 …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过安全副本(scp)将文件传输到我的Google云托管Linux(Debian)实例.我完全按照文档所说的从本地机器连接到实例.https://cloud.google.com/compute/docs/instances/connecting-to-instance.
我可以成功登录:
ssh -i ~/.ssh/my-keygen [USERNAME]@[IP]
Run Code Online (Sandbox Code Playgroud)
但是,当我想将文件复制到实例时,我收到一条消息"权限被拒绝".
scp -r -i ~/.ssh/my-keygen /path/to/directory/ [USERNAME]@[IP]:/var/www/html/
Run Code Online (Sandbox Code Playgroud)
看起来我登录的用户没有写文件的权限,所以我已经尝试更改/ var/www /的文件权限,但这仍然给出了权限被拒绝的消息.
我还尝试将用户添加到根组,但这仍然会出现同样的问题.
usermod -G root myuser
Run Code Online (Sandbox Code Playgroud) linux scp permission-denied google-compute-engine google-cloud-platform
我正在处理一个编辑按钮,当我单击该按钮时,我可以通过输入字段编辑页面中的某些元素。因此,如果我单击具有 .editable 类的元素,则必须将其更改为输入字段,并且该值必须是元素中的文本。当我再次单击保存(编辑)按钮时,必须将值更改为新值。
(我知道我必须将新数据保存在数据库中,但这并不重要。此页面的工作方式类似于编辑按钮必须如何工作的示例)。
这是例如我的 html:
编辑按钮<li>
<p><strong>Phone number:</strong><span class="editable">Some text which can be edited.</span>
</li>
Run Code Online (Sandbox Code Playgroud)
我的jQuery代码:
$("#edit").click(
function() {
$("#edit").text('Save');
$(document).find('.editable').each(function() {
$(this).replaceWith("<input>");
});
});
Run Code Online (Sandbox Code Playgroud) 在我的jsFiddle示例中,您可以看到我创建了一个按钮,我添加了一些元素和链接来删除这些元素.在此示例中,它不是要删除元素,而是悬停通过单击按钮创建的(删除)链接,以便突出显示具有相同"number"属性的元素.
我曾尝试使用live();和on();它,但它不会做任何事情,因为项目正在建设的页面后作出的.
我更喜欢on();现在使用,因为jQuery说:
从jQuery 1.7开始,不推荐使用.live()方法.使用.on()附加事件处理程序.旧版jQuery的用户应该使用.delegate()而不是.live().
我的jQuery代码:
function numbers() {
return $('#links span').length;
}
$('#add').on('click', function () {
$('#links').append('<span number="' + (numbers() + 1) + '">Remove element ' + (numbers() + 1) + '</span><br />');
$('#elements').append('<div number="' + numbers() + '" class="element">Element ' + numbers() + '</div>');
});
$('#links span').live('hover', function () {
var number = $(this).attr('number');
if ($('#elements .element').attr('number') == number) {
$(this).addClass('highlight');
}
});
Run Code Online (Sandbox Code Playgroud) 我有以下元素代表调查中的按钮:
<button name={id} value={value} onclick={handleChoiceClick} className="choice__button">
<img src={image} className="choice__button-image"/>
<span className="choice__button-title">Button title</span>
</button>
Run Code Online (Sandbox Code Playgroud)
该handleChoiceClick函数触发handleChange函数并通过按钮的名称和值存储一些数据:
const handleChoiceClick = (e) => {
handleChange(e.target.name, e.target.value);
};
Run Code Online (Sandbox Code Playgroud)
这工作正常,但是当我单击按钮(图像或跨度)内的子元素之一时,该handleChoiceClick函数会获取另一个 event.target 作为参数,并且名称和值未定义。
解决这个问题的最佳方法是什么?检查event.target内部handleChoiceClick还是有更简单的方法吗?