嗨,我正在尝试做一些基本的JavaScript,并得到"本机代码"而不是我想要的:
<script type="text/javascript">
var today = new Date();
document.write(today + "<br />");
//document.write(today.length + "<br />"); - was getting "undefined"
//document.write(today[0] + "<br />"); - was getting "undefined"
document.write(today.getMonth + "<br />");
document.write(today.getMonth + "<br />");
document.write(today.getFullYear + "<br />");
</script>
Run Code Online (Sandbox Code Playgroud)
输出是:
Fri Jan 13 14:13:01 EST 2012
function getMonth() { [native code] }
function getDay() { [native code] }
function getFullYear() { [native code] }
Run Code Online (Sandbox Code Playgroud)
我想要的是获取当前的Month,Day,Year并将其放入我稍后可以调用的数组变量中.由于这个原生代码,我没有走得太远.有人可以告诉我它是什么,希望更重要的是我可以完成这个项目吗?感谢您的时间和帮助,非常感谢!
我是mysqli的新手,正在阅读以下教程:http://www.binpress.com/tutorial/using-php-with-mysql-the-right-way/17#comment1
我能够使用以下方法连接到我的数据库:
$config = parse_ini_file('../config.ini');
$connection = mysqli_connect('localhost',$config['username'],$config['password'],$config['dbname']);
if($connection === false) {
die('Connection failed [' . $db->connect_error . ']');
}
echo("hello"); //this worked!
Run Code Online (Sandbox Code Playgroud)
但后来我尝试将它包装在一个函数中(如教程中所讨论的)...我看到你从另一个函数调用连接函数...在教程中,每个函数都会从另一个函数和另一个函数调用...而我从来没有找到初始调用开始从哪里获得函数调用彼此的多米诺骨牌效应..所以无论如何,我试图阻止它只是为了测试和教自己..但它不起作用,我不知道为什么:
function db_connect() {
static $connection;
if(!isset($connection)) {
$config = parse_ini_file('../config.ini');
$connection = mysqli_connect('localhost',$config['username'],$config['password'],$config['dbname']);
}
if($connection === false) {
return mysqli_connect_error();
}
return $connection;
echo("hello2");
}
function db_query($query) {
$connection = db_connect();
$result = mysqli_query($connection,$query);
return $result;
echo("hello1");
}
db_query("SELECT `Q1_Q`,`Q1_AnsA` FROM `Game1_RollarCoaster`"); //this didn't work :(
Run Code Online (Sandbox Code Playgroud)