所有由罗佳(博主)发布的文章

mysql的蛋疼注意事项一条

今天一个神一般的问题纠结了我一天。。
那就是Mysql创建table的时候,语法问题。

本来是想做个ip记录模块的,结果时间都浪费在这里了。接下来是高能重点!!!!

$info = "CREATE TABLE ips
(
number int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(number),
ip varchar(30)
)";
mysql_query($info,$sql);

上面这是修改后正确的代码(其中一个原来出错的部分),先来猜猜原来是哪里出错了呢~~~~

 

 

 

 

希望这是大多数人都遇到过的问题,接下来公布答案。。

那就是ip varchar(30)这个了,不得不说mysql解析的智能程度还不够,我只是在最后加了个,而已,它就不认爹了【也就是ip varchar(30),】

接下来是错误版

$info = "CREATE TABLE ips
(
number int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(number),
ip varchar(30),   //←注意这个悲催的逗号,难道逗号后面没有参数它就不能当作空参数吗!执行到这里就直接当作错误跳过了【坑爹呐!!!(掀桌子)】
)";
mysql_query($info,$sql);

值得庆幸的是。。我终于发现并解决了这个问题。ip记录模块还有希望的说喵~~

太阳君和月亮酱

上个例子先。。

然后由于某些原因。。在文章后面的这个太阳或者月亮就是例子了。

单独的例子看这里:demo.luojia.me/sunandmoon/

————下面是神圣的代码————–

 

<html>
<head>
<script src="http://www.luojia.tk/jquery.js"></script>
<script>
function resunmoondivsize(){
var height=window.innerHeight;
var width=window.innerWidth;
if(height>width){
document.getElementById("sunmoondiv").style.width=width*2;
document.getElementById("sunmoondiv").style.height=width*2;
}
else{
document.getElementById("sunmoondiv").style.width=height*2;
document.getElementById("sunmoondiv").style.height=height*2;
}
document.getElementById("sunmoondiv").style.left=(width-document.getElementById("sunmoondiv").style.width);

var divwidth=document.getElementById("sunmoondiv").style.width;
var divheight=document.getElementById("sunmoondiv").style.height;
var setwidth=width/2;
var setdivwidth=divwidth/2;
document.getElementById("sunmoondiv").style.left=setwidth-setdivwidth;
document.getElementById("sunmoondiv").style.top=divheight/2;

}
function setsunmoon(){
var divwidth=document.getElementById("sunmoondiv").style.width;
var sunwidth=document.getElementById("sun").style.width;
var moonwidth=document.getElementById("moon").style.width;
}
sunshinejiaodu=0;
function zhuansunshine(){
sunshinejiaodu=sunshinejiaodu+0.4;
var jiaodu="rotate("+sunshinejiaodu+"deg)";
$("#sunshine").css({"transform":jiaodu,"-webkit-transform":jiaodu,"-moz-":jiaodu,"-ms-":jiaodu,"-o-":jiaodu});
}
function zhuansunmoon(){
var date=new Date();
var zhengtijiaodu=(date.getHours()*60+date.getMinutes()+date.getSeconds()/60)*0.25;
var jiaodu="rotate("+zhengtijiaodu+"deg)";
$("#sunmoondiv").css({"transform":jiaodu,"-webkit-transform":jiaodu,"-moz-":jiaodu,"-ms-":jiaodu,"-o-":jiaodu});
}
</script>
</head>
<body style="margin: 0px;">
<div style="position:fixed;height:100%;width:100%;overflow:hidden;min-height:360px;min-width:360px;" id="sunmoonmain">
<div style="position:relative;min-height:360px;min-width:360px; margin:0px auto;" id="sunmoondiv">
<!--月亮酱-->
<div style="position:absolute;height:180px;width:180px;overflow:hidden;top:0px;left:50%; margin-left:-90px;transform:scale(0.5);-webkit-transform:scale(0.5);-o-transform:scale(0.5);-ms-transform:scale(0.5);-moz-transform:scale(0.5);" id="moon">
<div style="position:absolute;width:50%;height:50%;left:22.5%;top:22.5%;border-radius:999px; background-color:rgba(255,204,51,0.6)"></div>
</div>

<!--太阳君-->
<style>
div.suncolor{background-color:rgba(255,0,0,0.8);}
</style>
<div style="position:absolute;height:180px;width:180px;overflow:hidden;bottom:0px;left:50%; margin-left:-90px;transform:scale(0.5);-webkit-transform:scale(0.5);-o-transform:scale(0.5);-ms-transform:scale(0.5);-moz-transform:scale(0.5);" id="sun">
<div style="position:absolute;width:50%;height:50%;left:25%;top:25%;border-radius:999px;" class="suncolor"></div>
<div style="position:absolute;height:180px;width:180px;" id="sunshine">
<div style="position:absolute;width:3px;height:13%;left:88.5px;top:16px;" class="suncolor"></div>
<div style="position:absolute;width:13%;height:3px;top:88.5px;right:16px;" class="suncolor"></div>
<div style="position:absolute;width:3px;height:13%;left:88.5px;bottom:16px;" class="suncolor"></div>
<div style="position:absolute;width:13%;height:3px;top:88.5px;left:16px;" class="suncolor"></div>

<div style="position:absolute;height:180px;width:180px;transform:rotate(22.5deg);-webkit-transform:rotate(22.5deg);-moz-transform:rotate(22.5deg);-ms-transform:rotate(22.5deg);-o-transform:rotate(22.5deg);">
<div style="position:absolute;width:3px;height:7%;left:88.5px;top:26px;" class="suncolor"></div>
<div style="position:absolute;width:7%;height:3px;top:88.5px;right:26px;" class="suncolor"></div>
<div style="position:absolute;width:3px;height:7%;left:88.5px;bottom:26px;" class="suncolor"></div>
<div style="position:absolute;width:7%;height:3px;top:88.5px;left:26px;" class="suncolor"></div>
<div style="position:absolute;height:180px;width:180px;transform:rotate(22.5deg);-webkit-transform:rotate(22.5deg);-moz-transform:rotate(22.5deg);-ms-transform:rotate(22.5deg);-o-transform:rotate(22.5deg);">
<div style="position:absolute;width:3px;height:13%;left:88.5px;top:16px;" class="suncolor"></div>
<div style="position:absolute;width:13%;height:3px;top:88.5px;right:16px;" class="suncolor"></div>
<div style="position:absolute;width:3px;height:13%;left:88.5px;bottom:16px;" class="suncolor"></div>
<div style="position:absolute;width:13%;height:3px;top:88.5px;left:16px;" class="suncolor"></div>
<div style="position:absolute;height:180px;width:180px;transform:rotate(22.5deg);-webkit-transform:rotate(22.5deg);-moz-transform:rotate(22.5deg);-ms-transform:rotate(22.5deg);-o-transform:rotate(22.5deg);">
<div style="position:absolute;width:3px;height:7%;left:88.5px;top:26px;" class="suncolor"></div>
<div style="position:absolute;width:7%;height:3px;top:88.5px;right:26px;" class="suncolor"></div>
<div style="position:absolute;width:3px;height:7%;left:88.5px;bottom:26px;" class="suncolor"></div>
<div style="position:absolute;width:7%;height:3px;top:88.5px;left:26px;" class="suncolor"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(e) {
resunmoondivsize();
setsunmoon();
zhuansunmoon();
setInterval('zhuansunshine()',100);
setInterval('zhuansunmoon()',60000);
$(window).resize(function() {
resunmoondivsize();
});

});
</script>
</body>
</html>