我开发了登录系统.它完美地运作.现在我想获得最后的登录日期和时间并显示它.显示部分没问题.如果登录成功,我尝试使用此代码更新数据库中的logtime字段.
$query = "SELECT * FROM user WHERE email='$email' AND passwordR='$password' AND status='1' ";
$result = mysqli_query($con,$query)or die(mysqli_error($con));
$num_row = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
if( $num_row ==1 ) {
$_SESSION['user_name'] = $email;
$sql="UPDATE user SET logtime = now()";
mysqli_query($con,$query)or die(mysqli_error($con));
}
Run Code Online (Sandbox Code Playgroud)
我的logtime行定义如下,
`logtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
Run Code Online (Sandbox Code Playgroud)
怎么没有更新logtime.为什么
$sql="UPDATE user SET logtime = now()";
Run Code Online (Sandbox Code Playgroud)
不可能?
我想用 vanilla js 进行 ajax 调用。
在jQuery中,我有这个有效的 ajax 调用:
$.ajax({
url:"/faq/ajax",
datatype: 'json',
type:"POST",
data: {search:'banana'},
success:function(r) {
console.log(r['name'])
}
});
Run Code Online (Sandbox Code Playgroud)
普通JS:
var search = document.getElementById('searchbarfaq').value;
var r = new XMLHttpRequest();
r.open("POST", "/faq/ajax", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
console.log("Success: " + JSON.parse(r.responseText));
var a = JSON.parse(r.responseText);
console.log(a.name); //also tried a['name']...
};
r.send("search=banana");
Run Code Online (Sandbox Code Playgroud)
vanilla js 调用只是将其记录到控制台:
"Success: [object Object]"
Array [ ]
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我我做错了什么吗?
我有多个页面都使用顶部的简单选项卡菜单.菜单(aka列表)存储在单独的html文件中:
<ul>
<li id="Tab1"><a href='../Page1.html'> Page1 </a></li>
<li id="Tab2"><a href='../Page2.html'> Page2 </a></li>
<li id="Tab3"><a href='../Page3.html'> Page3 </a></li>
Run Code Online (Sandbox Code Playgroud)
每个页面都有<div id='tabs'> </div>
和
$('#tabs').load('CommonTabs.html');
Run Code Online (Sandbox Code Playgroud)
一切正常,我的标签加载到'标签'div.现在我想在每个页面上将一个div的类设置为"active",以便可以应用css中定义的正确样式.我试过了:
$('#tabs').load('CommonTabs.html');
$('#Tab1'.addClass("active");
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.当我在浏览器中执行"检查元素"时,li没有分配"活动"类.
以下是我的gulpfile.js.其中还有几个任务,并且一切正常 - 但最后一项任务watch
却没有.
我已经尝试了所有可能的路径和文件组合以及所有这些,但我仍然没有运气.我在这里已经阅读了很多答案,但无法解决我的问题.我尝试运行gulp.watch,不需要gulp-watch,尝试了几种不同的方法来设置任务等等......
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var watch = require('gulp-watch');
gulp.task('application', function() {
return browserify('./public/resources/jsx/application.js')
.transform(babelify, { stage: 0 })
.bundle()
.on('error', function(e){
console.log(e.message);
this.emit('end');
})
.pipe(source('appBundle.js'))
.pipe(gulp.dest('./public/resources/jsx'));
});
gulp.task('watch', function() {
gulp.watch('./public/resources/jsx/project/*.js',['application'])
});
Run Code Online (Sandbox Code Playgroud)
有人可以提出解决方案吗?
编辑:
这是控制台输出:
michael@michael-desktop:/opt/PhpstormProjects/app_april_2015$ gulp watch
[23:05:03] Using gulpfile /opt/PhpstormProjects/app_april_2015/gulpfile.js
[23:05:03] Starting 'watch'...
[23:05:03] Finished 'watch' after 13 ms
Run Code Online (Sandbox Code Playgroud) 我总是遇到CSS和JQuery的组合问题.谁能告诉我这里我做错了什么?我只是想移动我的div.感谢所有的解决方案,我想进一步了解.如何在不同方向上多次移动它?
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
jQuery(document).ready(function () {
jQuery("#hello").mouseenter(function () {
jQuery("#hello").animate({ left: '150px' }, slow);
});
});
</script>
<div id="hello">
Hello World!
</div>
<style>
#hello{
color: gray;
background-color: gold;
width: 125px;
height: 125px;
position: fixed;
left: 350px;
top: 350px;
border-width: 2px;
border-color: lavender;
text-align: center;
}
</style>
Run Code Online (Sandbox Code Playgroud) 我正在尝试相对于其按钮或使用 jquery 单击的按钮来定位弹出窗口。我想以不覆盖按钮本身的方式定位弹出窗口。将其放置在单击的按钮的左侧、右侧、上方或下方。
现在我知道我可以通过编写更多的 html 弹出窗口和 css 来做到这一点,但必须有一种方法来动态使用一个 div 并用 jquery 定位它。我尝试使用偏移量和位置(在某一点),但我无法让它工作。坦率地说,我对 js 和 jquery 非常入门,所以请原谅我的菜鸟。
任何帮助将不胜感激!!
JS:
$('.trends').click(function () {
$('.questions').fadeIn();
$('.question').html('<p>What trends could potentially drive growth in the U.S.?</p>');
/* if I add this and zero out the positioning via css the pop gets offset but its way far away from this parent.
var offset = $(this).offset();
$('.questions').css('left',offset.left);
$('.questions').css('top',offset.top);*/
});
$('.consumer').click(function () {
$('.questions').fadeIn();
$('.question').html('<p>Even though we have low inflation, consumers are not increasing their spending. Why?</p>');
}); …
Run Code Online (Sandbox Code Playgroud) 我正在使用多个队列,并希望将事件推送到另一个队列而不是默认队列.
我有一个实现ShouldQueue的标准事件类,但是如何指定此事件将被推送到的队列?
我试过了
class NewMessageArrived extends Event implements ShouldQueue
{
use SerializesModels;
protected $queue = 'redis';
....
Run Code Online (Sandbox Code Playgroud)
但这不符合我的要求.有没有办法做到这一点?
我仍然相当新编码,并一直在解决一些算法问题.我有一个告诉我使用数组,并以此为例:
([1, 2, 3, 4], 1.5)
Run Code Online (Sandbox Code Playgroud)
在这个例子中我如何访问1.5?或者方括号中的部分,就此而言.方括号中的部分是通过数组名称然后[0]或我想访问的数字来访问的吗?
运行以下代码并按下按钮应该会记录到控制台窗口 2 个元素,即带有class="test1"
、按钮和 的p
元素。并且console.log(el.length)
是2
。但控制台记录的内容是这样的:
[p#div1.test1,
button#btn.test1,
div1: p#div1.test1,
btn: button#btn.test1]
Run Code Online (Sandbox Code Playgroud)
看起来4
元素不是2
。
这里发生了什么?
<html>
<body>
<p class="test1" id="div1">test1</p>
<button id="btn" onclick="getElements()" class="test1">Get Element List</button>
<script>
function getElements()
{
var txt = document.getElementById("div1").innerHTML;
var el = document.getElementsByClassName(txt);
if (el) {
console.log(el);
console.log(el.length);
}
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) DateTime 类(以及 DatePeriod 和 DateInterval)似乎在我当前的服务器上不起作用。PHP 5.3.3 是根据 phpinfo 页面安装的,当我将 get_declared_classes() 函数作为数组运行以查看定义了哪些类时,这些类似乎确实存在:
数组([0] => stdClass [1] => Exception [2] => ErrorException [3] => Closure [4] => DateTime [5] => DateTimeZone [6] => DateInterval [7] => DatePeriod [8] => LibXMLError...
但是,即使我使用 DateTime 运行最简单的 PHP 代码,我也会收到 HTTP 500 错误:
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
Run Code Online (Sandbox Code Playgroud)
这种较旧的符号确实可以正常工作,
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
Run Code Online (Sandbox Code Playgroud)
但出于某种原因,DateTime 无法正常工作。我在不同的服务器上使用这些 DateTime 对象编写了一些代码,并且运行良好。关于我可能有错误的想法?是否有我应该考虑的 php.ini 或其他设置?
-JF