目前我正在攻读我的Java测试.惠斯特学习我遇到了一个小问题.
在这个for循环中:
for ( int i=1; i <= 3 ; i++ ) {
for (int j=1; j <= 3 ; j++ ) {
System.out.println( i + " " + j );
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
Run Code Online (Sandbox Code Playgroud)
我的问题是,我不明白.当我读到这段代码时,我一直认为它应该是这样的:
1 1
2 2
3 3
Run Code Online (Sandbox Code Playgroud)
为什么不是这样?
docker-compose.yml
version: "3"
services:
sqlite3:
image: nouchka/sqlite3:latest
stdin_open: true
tty: true
volumes:
- ./db/:/root/db/
app:
build:
context: ../
dockerfile: build/Dockerfile
ports:
- "5000:5000"
volumes:
- ../:/app
command: pipenv run gunicorn --bind=0.0.0.0:5000 --reload app:app
Run Code Online (Sandbox Code Playgroud)
现在我如何让我的 Flask 应用程序连接到我的 dockerized 数据库?
SQLALCHEMY_DATABASE_URI = 'sqlite:///db.sqlite'
(我不知道在这里放什么来连接到 Docker 镜像数据库)
你怎么写一个准备好的更新声明?参考:mysqli :: prepare
我试过按照描述编写它:
if ($stmt = $mysqli->prepare("UPDATE tblFacilityHrs SET title =? description = ? WHERE uid = ?")){
$stmt->bind_param('sss', $title, $desc, $uid2);
//Get params
$title=$_POST['title'];
$desc=$_POST['description'];
$uid2=$_GET['uid'];
$stmt->execute();
$stmt->close();
}
else {
//Error
printf("Prep statment failed: %s\n", $mysqli->error);
}
Run Code Online (Sandbox Code Playgroud)
错误:
准备语句失败:您的SQL语法出错; 检查与MySQL服务器版本对应的手册,以便在'description =附近使用正确的语法?在哪里uid =?' 在第1行编辑的行.
我在PHP中有一个论坛,它采用类似于表单的日期
dd/mm/yyyy hh:mm:ss
.但是,我需要将其作为DATETIME以SQL格式插入SQL yyyy-mm-dd hh:mm:ss
.我该如何转换这些数据?
有人可以帮助调试此错误吗?
警告:preg_replace()[function.preg-replace]:编译失败:在偏移量1处不重复
//Generate uid
function gen_uid($len=40) {
$hex = md5("what" . uniqid("", true));
$pack = pack('H*', $hex);
$tmp = base64_encode($pack);
$uid = preg_replace("#(*UTF8)[^A-Za-z0-9]#", "", $tmp);
$len = max(4, min(128, $len));
while (strlen($uid) < $len)
$uid .= gen_uid(22);
return substr($uid, 0, $len);
}
Run Code Online (Sandbox Code Playgroud)
是什么导致这个?它是PHP问题还是其他什么?应用程序在我的本地计算机上运行正常但在服务器上运行不正常
谁能告诉我这里我做错了什么?
#!/bin/sh
if [ $# = 0 ]
then
echo "Usage: $0 <filename>"
exit 1
fi
sum=0
count=0
while [ $0 != 0 ]
do
sum="$sum"+"$2"
count="$count"+ 1
done
if [ "$count" != 0 ]
then
avg="$sum"/"$count"
printf "Sum= $sum \n Count= $count \n Avg= $avg"
exit 0
else
printf "Sum= $sum \n Count= $count \n Avg= undefined"
exit 0
fi
exit 1
Run Code Online (Sandbox Code Playgroud)
这是我尝试测试代码时的输出:
./average
sum: =: No such file or directory
sum: 0: No such file or directory
./average: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个小型 html5 网页,要求用户输入评论及其电子邮件地址。如果他们不输入评论和/或电子邮件,系统将通过 JavaScript 提示他们修正输入。我遇到的问题是 JavaScript 根本无法运行。我认为它被完全跳过了。请告诉我哪里错了......
\n\n <!DOCTYPE HTML>\n<html lang="en-US">\n<link rel="icon" type="image/png" href="img/favicon.png">\n<link rel="stylesheet" type="text/css" href="css/new.css">\n<title>Comments</title>\n</head>\n<body>\n<nav id="navbar"> Navigation:\n <table><tr>\n <td><a href="bio.html">Bio</a></td>\n <td><a href="resume.html">Resume</a></td>\n <td><a href="classes.html">Classes</a></td>\n <td><a href="new.html">New</a></td>\n </tr></table>\n</nav>\n\n<header> \n <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>\n<script type="text/javascript>\n\n\nfunction yay () {\nif (document.poop.melon.value == "" || document.poop.melon.value == "Type comment here!" || document.poop.melon.value == "..." )\n{\n alert ( "Fill in the comment box you poopyhead!" );\n document.poop.melon.value = "Type comment here!";\n return false;\n}\nif (document.poop.maplestory.value == "youremail@mail.com" || document.poop.maplestory.value == "" || maplestory (document.poop.maplestory.value)){\n alert ("Dear …
Run Code Online (Sandbox Code Playgroud) 编辑:这是我更新的代码:
#!/bin/sh
files=`ls`
if [ $# -ne 1 -o -f $1 ]
then
echo "Usage: $0 <directory>"
exit 1
fi
if [ ! -e $1 ]
then
echo "$1 not found"
exit 1
elif [ -d $1 ]
then
cd $1
for f in $files
do
if [ ! -d "$f" ]
then
if [ ! -s "$f" ]
then
rm -r "$f"
echo "File: $f was removed."
else
continue
fi
fi
done
echo "Name\t\tLinks\t\tOwner\t\tDate"
for f in $files
do …
Run Code Online (Sandbox Code Playgroud) 在现实世界中,人们使用它来解决什么类型的问题?我可以看到这些协同工作的示例代码吗?我所能找到的只是关于猫狗说话或人们喝牛奶或咖啡的代码......
人们真的用接口实现多态吗?做什么的?
我有一些这样的php代码:
$row = mysql_fetch_array ( mysql_query("SELECT * FROM `tblFacilityHrs` WHERE `uid` = '$uid'"));
Run Code Online (Sandbox Code Playgroud)
我现在正尝试将其转换mysqli_fetch_array
为此处所示的http://php.net/manual/en/mysqli-result.fetch-array.php(示例1面向对象样式)
我不确定“ $ result”示例的含义。
到目前为止,这是我将代码转换为的内容:
<?php
include('../config.php');
if (isset($_GET['uid']) ) {
$uid = $_GET['uid'];
$id = $_GET['id'];
if (isset($_POST['submitted'])) {
foreach($_POST AS $key => $value) { $_POST[$key] = mysqli_real_escape_string($value); }
//Query for tblFacilityHrs
$sql = " UPDATE tblFacilityHrs SET `title`='{$_POST['title']}',`description`='{$_POST['description']}' WHERE `uid` = '$uid' ";
$result = $mysqli->query($sql) or die($mysqli->error);
//Query for tblFacilityHrsDateTimes
$sql2 = "UPDATE tblFacilityHrsDateTimes SET `startEventDate`='{$_POST['startEventDate']}',`endEventDate`='{$_POST['endEventDate']}', `startTime`='{$_POST['startTime']}',`endTime`='{$_POST['endTime']}',`days`='{$_POST['days']}',`recurrence`='{$_POST['recurrence']},`finalDate`='{$_POST['finalDate']}' WHERE `id` = …
Run Code Online (Sandbox Code Playgroud) 有人可以看一下这段代码并找出它有什么问题吗?
#!/bin/sh
while :
do
echo " Select one of the following options:"
echo " d or D) Display today's date and time"
echo " l or L) List the contents of the present working directory"
echo " w or W) See who is logged in"
echo " p or P) Print the present working directory"
echo " a or A) List the contents of a specified directory"
echo " b or B) Create a backup copy of an ordinary …
Run Code Online (Sandbox Code Playgroud) 有什么我可以用来看看一个数字是否与另一个数字相同?防爆.5643和5377都以5开头.
有没有办法用数字做这个或者它们必须是字符串?(以..开始?)
我正在尝试编写一个小程序,在数组中打印出不同的数字.例如,如果用户输入1,1,3,5,7,4,3,程序将只打印1,3,5,7,4.
如果函数中的行,我在else上收到错误checkDuplicate
.
到目前为止,这是我的代码:
import javax.swing.JOptionPane;
public static void main(String[] args) {
int[] array = new int[10];
for (int i=0; i<array.length;i++) {
array[i] = Integer.parseInt(JOptionPane.showInputDialog("Please enter"
+ "an integer:"));
}
checkDuplicate (array);
}
public static int checkDuplicate(int array []) {
for (int i = 0; i < array.length; i++) {
boolean found = false;
for (int j = 0; j < i; j++)
if (array[i] == array[j]) {
found = true;
break;
}
if (!found)
System.out.println(array[i]);
}
return 1; …
Run Code Online (Sandbox Code Playgroud) java ×4
php ×4
bash ×3
mysqli ×3
syntax-error ×3
arrays ×1
docker ×1
duplicates ×1
for-loop ×1
html ×1
interface ×1
javascript ×1
logic ×1
mysql ×1
oop ×1
polymorphism ×1
preg-replace ×1
python ×1
regex ×1
scripting ×1
shell ×1
sql ×1
sqldatatypes ×1
sqlite ×1
startswith ×1
unix ×1
xss ×1