RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-307972

JustLearn's questions

Martin Hope
JustLearn
Asked: 2020-09-16 04:54:15 +0000 UTC

如何确保在页面重新加载后表单中输入的数据不会重新输入到数据库中,这种行为在网站上是否可以接受?[复制]

  • 0
这个问题已经在这里得到了回答:
如何避免更新时重新提交表单? (5 个回答)
2年前关闭。

数据库中有一个名为 temp1 的用户表。
用户有两列:姓名和姓氏。
名字和姓氏是通过表格输入的。数据已成功输入数据库。但我注意到,如果您重新加载页面并接受重新提交表单,那么数据会再次输入数据库。

网站可以接受这种行为吗?这被认为是一个错误吗?如何解决?

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style rel="stylesheet">
            label {
                width: 150px;
            }
            .input-area {
                margin-bottom: 15px;
            }
        </style>
    </head>
    <body>

        <form action="" method="POST">
            <div class="input-area">
                <label>Имя</label>
                <input type="text" name="name">
            </div>
            <div class="input-area">
                <label>Фамилия</label>
                <input type="text" name="surname">
            </div>
            <div class="input-area">
                <input type="submit" value="Занести данные в базу">
            </div>
        </form>
        <?php
            if ($_SERVER["REQUEST_METHOD"] == "POST") {
                $pdo = new PDO("mysql:host=localhost;dbname=temp1", "root", "");
                $name = htmlentities(trim($_POST["name"]));
                $surname = htmlentities(trim($_POST["surname"]));
            
                $stmt = $pdo->prepare("INSERT INTO users(name, surname) VALUES(?, ?)");
                $stmt->execute([$name, $surname]);
        ?> 
    </body>
</html>
php
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-09-13 06:32:24 +0000 UTC

为什么 alert() 和以下命令不起作用?

  • 0

let valid = true;
let x = prompt("Введите x", "");
if (x == null || x == "") {
  alert("Вы не ввели x");
  valid = false;
}

if (valid == true) {
  let n = prompt("Введите n", "");
  if (n == null || n == "") {
    alert("Вы не ввели n");
    valid = false;
  }
  alert("n = " + n);
  alert(valid);
}

function pow(x, n) {
  let poweredNumber = 1;
  for (let i = 0; i < n; i++) {
    poweredNumber *= x;
  }
  return poweredNumber;
}
alert("Перед if");
if (valid == true) {
  alert("В if");
  alert(pow(x, n)); //Почему-то не срабатывает
}
alert("После if"); //Почему-то не срабатывает

我用注释标记的部分不起作用。但只有当你声明一个有效的变量并写下前两个 if 时,它才起作用。如果没有有效且前两个 if 的,那么一切正常。事实上,一切都应该工作,但有些事情是不对的......

javascript
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-07-11 19:37:50 +0000 UTC

为什么我不能将页面参数添加到 url?

  • 0

我正在写一个类似迷你博客的东西,我想通过 url 参数实现一个页面计数器。
该站点有一个链接,该链接的地址已经设置了页面参数:

<a href="articles_page.php?page=1">Открыть список статей</a>

但是我想让它即使用户在地址栏中手动键入articles_page.php,也会添加值为1的页面参数。
在articles_page.php页面上,一开始就嵌入了php代码:

<?php
    if (strpos($_SERVER["REQUEST_URL"], "page") === false) { //line 2
        $_SERVER["REQUEST_URL"] .= "?page=1"; //line 3
    }
?>

但是如果你输入 url article_page.php,那么你会得到错误:
Notice: Undefined index: REQUEST_URL in C:\xampp\htdocs\blog\articles_page.php on line 2
Notice: Undefined index: REQUEST_URL in C:\xampp\ htdocs\blog\articles_page.php on line 3

问题:为什么会抛出这些错误,如何正确实现?

php
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-06-06 22:52:41 +0000 UTC

为什么我不能创建显式函数模板特化?

  • 1
#include <iostream>
#include <conio.h>
using namespace std;
template <class T>
T Max(T a, T b) {
    return a > b ? a : b;
}
struct box {
    double height;
    double width;
    double length;
    double volume;
};
void setVolume(box &b) {
    b.volume = b.height * b.width * b.length;
}
template <> double Max<box>(box b1, box b2) { //Ошибка
    return b1.volume > b2.volume ? b1.volume : b2.volume;
}
int main() {
    box b1 = { 5, 4, 2 };
    box b2 = { 10, 10, 2 };
    setVolume(b1);
    setVolume(b2);
    cout << Max(b1, b2) << endl;
    _getch();
    return 0;
}

错误 C2912 显式特化;"double Max(box,box)" 不是函数特化

c++
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-06-03 18:01:26 +0000 UTC

是否可以通过这种方式从函数返回本地指针?

  • 0

在 S. Prat 的书中,我遇到了一个例子:

struct free_throws {
     int made;
     int attempts;
     double percent;
};
const free_throws & clone(free_throws &ft) {
     free_throws *pt;
     pt = &ft;
     return *pt;
}

据我了解,您不能通过引用或地址返回局部变量,因为它们将在函数结束时被销毁,并且将返回对已经不存在的变量的引用,即 为“垃圾”。

问题:是否可以像这样返回本地指针变量?为什么?

c++
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-05-25 21:04:50 +0000 UTC

如何覆盖下拉元素上的 :active 伪类属性?

  • 0

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  <title></title>
  <style>
    .dropdown:hover .dropdown-menu {
      display: block;
      margin-top: 0;
    }
  </style>
</head>

<body>
  <nav class="navbar navbar-dark bg-dark navbar-expand-sm">
    <a href="" class="navbar-brand">MySite</a>
    <button class="navbar-toggler" data-toggle="collapse" data-target="#navbar">
           <span class="navbar-toggler-icon"></span>
       </button>
    <div class="collapse navbar-collapse" id="navbar">
      <ul class="navbar-nav nav-items ml-auto">
        <li class="nav-item">
          <a href="" class="nav-link">Главная</a>
        </li>
        <li class="nav-item dropdown">
          <a href="" class="nav-link dropdown-toggle" data-toggle="dropdown">О нас</a>
          <div class="dropdown-menu dropdown-menu-right">
            <a href="" class="dropdown-item">Blog</a>
            <a href="" class="dropdown-item">YT</a>
            <a href="" class="dropdown-item">VK</a>
          </div>
        </li>
      </ul>
    </div>
  </nav>


  <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>

</html>

我有一个 .dropdown 元素,其默认点击行为设置为 (:active)。我这样做是为了使列表在悬停在此元素上时也会退出。

问题:我怎样才能让元素只有在悬停在它上面时才会退出,即 这样 :active 伪类就不会触发?

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-05-20 04:47:14 +0000 UTC

为什么导航栏中的链接会向右移动?

  • 1

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<nav class="navbar navbar-dark bg-dark">
  <a href="" class="navbar-brand">
    MyBrandName
  </a>
  <ul class="nav nav-pills">
    <li class="nav-item">
      <a href="" class="nav-link">Home</a>
    </li>
    <li class="nav-item">
      <a href="" class="nav-link">Home</a>
    </li>
    <li class="nav-item">
      <a href="" class="nav-link active">Home</a>
    </li>
  </ul>
</nav>


<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

我是按照 YouTube 上的教程做的,在那个视频中,3 个主页链接被压到了左边,但出于某种原因,它们被压到了右边。可能是什么问题呢?

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-05-02 03:54:57 +0000 UTC

为什么块的位置有一个巨大的缩进?

  • 0

问题:为什么该块.break位于h1带有巨大缩进的块中440px?
我没有在代码中的任何地方指定它。
如何解决?

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: rgba(47, 60, 255, 0.49);
}

.container {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 1600px;
}

.wrapper {
  display: flex;
  justify-content: center;
  background: #303f62;
  height: calc(100vh - 150px);
  min-height: 1100px;
  width: 100%;
}

.content-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  background: #e3ffa2;
  width: 80%;
}

.content {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  height: 80%;
  margin-top: 50px;
  background: red;
}

h1 {
  display: flex;
  text-align: center;
  height: 50px;
  margin: 0 auto 30px auto;
}

.break {
  height: 0;
  width: 100%;
}
<div class="container">
  <div class="wrapper">
    <div class="content-wrap">
      <div class="content">
        <h1>О нас</h1>
        <div class="break"></div>
      </div>
      <div class="break"></div>
    </div>
  </div>
</div>

html
  • 2 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-05-01 04:10:39 +0000 UTC

为什么它会抛出与函数指针相关的错误?

  • 0

共有三个功能:

const double *f1(const double ar[], int n);
const double *f2(const double ar[], int n);
const double *f3(const double ar[], int n);

两个函数指针:

const double *(*p1)(const double *, int) = f1;
auto p2 = f2;

使用指针:

cout << (*p1)(av, 3) << ": " << *(*p1)(av, 3) << endl;
cout << p2(av, 3) << ": " << *p2(av, 3) << endl;

我对指针使用两种类型的工作: (*p1)(av, 3) 和 p2(av, 3) 并且没有给出任何错误。
但是由于某种原因,在使用函数指针数组时它不能这样工作:

const double *(*pa[3])(const double *, int) = { f1, f2, f3 }; //Массив из трех указателей
cout << pa[0](av, 3) << ": " << *pa[0](av, 3) << endl;
cout << (*pa)[0](av, 3) << ": " << *(*pa)[0](av, 3) << endl; //Выдает ошибку. Почему?

这里我也使用了两种形式的指针操作,但是使用数组会产生错误。
第二个类似的例子:

const double * (*(*pd)[3])(const double *, int) = &pa;
const double *pdb = (*pd)[0](av, 3);
const double *pdb = pd[0](av, 3); //Снова выдает ошибку. По идее я использую вторую форму обращения к 
//указателя на функцию и все должно работать, но почему-то генерируется ошибка.

所以问题是:为什么在使用指向函数的指针时两种形式的访问指针都有效,但在使用指向函数的指针数组或指向函数指针数组的指针时出现问题?

PS要求:如果可能,请给出与上述示例相关的答案。

提前致谢

c++
  • 2 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-04-30 17:44:56 +0000 UTC

如何在不保存文件的情况下自动显示实时预览括号中的更改?

  • 0

仅当您保存文件时,实时预览期间对文件的更改才会生效。如何使更改自动显示?

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-04-29 20:33:58 +0000 UTC

为什么元素不换行?

  • 0

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: rgba(47, 60, 255, 0.49);
}

.container {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 1600px;
}

nav {
  display: flex;
  flex-grow: 1;
  background: #303f62;
  height: 150px;
  width: 100%;
}

ul {
  display: flex;
  padding: 0;
  height: 125px;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
}

.left {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 15px;
}

.left img {
  margin-left: 15px;
}

.right {
  margin-top: 0px;
  margin-left: auto;
  margin-right: 10%;
}

ul>a {
  margin-right: 5px;
  width: 150px;
  border: 1px solid transparent;
  text-align: center;
  color: #fff;
  background: #1e625b;
}

ul>a:hover {
  background: #29857d;
  cursor: pointer;
}

.on {
  color: red;
}

.wrapper {
  display: flex;
  justify-content: center;
  background: #303f62;
  height: calc(100vh - 150px);
  min-height: 1100px;
  width: 100%;
}

.links>a {
  margin-bottom: 20px;
  text-decoration: none;
  color: #fff;
}

.links>a:hover {
  color: #00856b;
}

.content-wrap {
  display: flex;
  flex-direction: row;
  background: #e3ffa2;
  width: 80%;
}

.content {
  display: flex;
  width: 100%;
  margin-top: 50px;
  background: red;
}

h1 {
  display: flex;
  text-align: center;
  height: 50px;
  margin: 0 auto 30px auto;
  margin-bottom: 100px;
}

.content-line {
  display: flex;
  flex-basis: 250px;
  height: auto;
  margin-bottom: 100px;
  margin-left: 30px;
  margin-right: 30px;
  max-width: 1200px;
}

.content-line:first-child {
  margin-top: 50px;
}

.section-left {
  display: flex;
  flex-direction: column;
  margin-left: auto;
}

.section-right {
  display: flex;
  flex-direction: column;
  margin-right: auto;
}

.text {
  text-align: center;
  font-size: 20px;
  color: #fff;
}

.break {
  height: 0;
  width: 100%;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="about_us.css">
</head>

<body>
  <div class="container">
    <nav>
      <div class="left">
        <img src="images/logo.jpg" height="100" alt="">
      </div>
      <div class="right">
        <ul>
          <a>Главная</a>
          <a class="on">О нас</a>
          <a>Контакты</a>
          <a>Партнеры</a>
        </ul>
      </div>
    </nav>
    <div class="wrapper">
      <div class="content-wrap">
        <div class="content">
          <h1>О нас</h1>
          <div style="margin-bottom: 50px" class="break"></div>
          <div class="content-line">
            <div class="section-left">
              <img src="images/img.jfif" height="200" alt="">
              <div class="text">Some text</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

为什么 content-line 元素不换行?我放置了 .break,但由于某种原因它不起作用:h1 和 .content-line 元素在同一行。问题是什么?如何解决?

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-04-02 20:34:26 +0000 UTC

为什么 justify-content 属性不适用于弹性项目?

  • 0

对于 .content-line , justify-content 属性由于某种原因不起作用。这个属性甚至在检查器中被划掉了。

问题:为什么这个属性不起作用?如何解决?

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

nav {
  display: flex;
  background: #303f62;
  height: 150px;
}

ul {
  display: flex;
  padding: 0;
  height: 125px;
  flex-wrap: wrap;
  padding: 10px;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
}

.left {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 15px;
  margin-right: auto;
}

.right {
  margin-top: 15px;
  margin-left: auto;
  margin-right: 10%;
}

ul>a {
  margin-right: 5px;
  width: 150px;
  border: 1px solid transparent;
  text-align: center;
  color: #fff;
  background: #1e625b
}

ul>a:hover {
  background: #29857d;
  cursor: pointer;
}

.wrapper {
  display: flex;
}

.sidebar {
  display: flex;
  flex-grow: 0;
  justify-content: center;
  align-items: flex-start;
  width: 20%;
  height: 600px;
  min-width: 200px;
  background: #303f62;
}

.sidebar .links {
  margin-top: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.links>a {
  margin-bottom: 20px;
  text-decoration: none;
  color: #fff;
}

.links>a:hover {
  color: #00856b;
}

.content {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-grow: 1;
  justify-content: flex-start;
  background: rgba(41, 41, 41, 0.3);
  height: 600px;
}

.content-line {
  display: flex;
  width: 200px;
  height: 200px;
  background: yellow;
}


/*Media Queries*/

@media all and (max-width: 920px) {
  ul {
    flex-direction: column;
  }
  ul a {
    margin-right: 0;
    margin-bottom: 5px;
  }
}
<body>
  <nav>
    <div class="left">
      <img src="logo1.jpg" alt="Лого">
    </div>
    <div class="right">
      <ul>
        <a>Главная</a>
        <a>О нас</a>
        <a>Контакты</a>
        <a>Сотрудники</a>
      </ul>
    </div>
  </nav>
  <div class="wrapper">
    <div class="sidebar">
      <div class="links">
        <a href="#">Статьи</a>
        <a href="#">Домой</a>
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
      </div>
    </div>


    <div class="content">
      <div class="content-line">

      </div>
    </div>
  </div>
</body>

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-04-01 04:56:02 +0000 UTC

Flexbox - 为什么链接不是排成一列,而是排成一行?

  • 0

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

nav {
  display: flex;
  background: #303f62;
  height: 150px;
}

ul {
  display: flex;
  padding: 0;
  height: 125px;
  flex-wrap: wrap;
  padding: 10px;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
}

.left {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  margin-top: 15px;
  margin-right: auto;
}

.right {
  margin-top: 15px;
  margin-left: auto;
  margin-right: 10%;
}

ul>a {
  margin-right: 5px;
  width: 150px;
  border: 1px solid transparent;
  text-align: center;
  color: #fff;
  background: #1e625b
}

ul>a:hover {
  background: #29857d;
  cursor: pointer;
}

aside {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 20%;
  height: 600px;
  min-width: 220px;
  background: #303f62;
}

aside .links {
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.links>a {
  text-decoration: none;
  color: #fff;
}

.links>a:visited {
  text-decoration: none;
  color: #fff;
}


/*Media Queries*/

@media all and (max-width: 920px) {
  ul {
    flex-direction: column;
  }
  ul a {
    margin-right: 0;
    margin-bottom: 5px;
  }
}
<nav>
  <div class="left">
    <img src="logo1.jpg" alt="Лого">
  </div>
  <div class="right">
    <ul>
      <a>Главная</a>
      <a>О нас</a>
      <a>Контакты</a>
      <a>Сотрудники</a>
    </ul>
  </div>
</nav>
<div class="section">
  <aside>
    <div class="links">
      <a href="#">Статьи</a>
      <a href="#">Домой</a>
      <a href="#"></a>
      <a href="#"></a>
      <a href="#"></a>
    </div>
  </aside>
</div>

问题:为什么 .links 块中的链接不排成一列?以及如何让它们排成一列

html
  • 2 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-03-23 18:24:13 +0000 UTC

为什么 phpstorm 不允许在调试模式中包含引导库(实时编辑)

  • 0
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

    <title></title>
  </head>
  <body>
  <span class="badge badge-primary">Hello world</span>


    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  </body>
</html>

如果您只是运行代码,那么一切都会好起来的。但是如果我在调试模式下运行文件(为了使用实时编辑),css 代码将无法工作,phpstorm 会出于某种原因阻止脚本和 css 文件。
问题:如何使在调试模式下包含第三方脚本和 css 成为可能?

PS错误列表:

CORS 策略已阻止从源“ http://localhost:63342 ”访问“ https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js ”处的脚本:对预检的响应请求没有通过访问控制检查:它没有 HTTP ok 状态。

获取https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js net::ERR_FAILED

从源“ http://localhost:63342 ”访问位于“ https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css ”的 CSS 样式表已被 CORS 策略阻止:响应预检请求未通过访问控制检查:它没有 HTTP ok 状态。

获取https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css net::ERR_FAILED

从源“ http://localhost:63342 ”访问“ https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js ”脚本已被阻止CORS 策略:预检响应中的 Access-Control-Allow-Headers 不允许请求标头字段 x-ijt。

获取https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js net::ERR_FAILED

CORS 策略已阻止从源“ http://localhost:63342 ”访问“ https://code.jquery.com/jquery-3.4.1.slim.min.js ”处的脚本:对预检请求的响应不't 't pass access control check: 请求的资源上不存在“Access-Control-Allow-Origin”标头。

获取https://code.jquery.com/jquery-3.4.1.slim.min.js net::ERR_FAILED

html
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-03-11 04:59:41 +0000 UTC

当我按下 Enter 键时,如何让 PhpStorm 的 Emmet 插件触发,就像 VS Code 一样?

  • 0

假设在 VS Code 中我输入一个 div 并按 Enter,它立即变为:div /div。或者我输入ul>li*5回车,Emmet插件也可以了。

以及如何让 Emmet 插件在 PhpStorm 中按照 Vs Code 原理工作,而不是在按下 CTRL + ALT +] 组合时?

php
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-02-27 17:37:07 +0000 UTC

如何确定单击了哪个提交按钮(仅使用 PHP 工具)?

  • 0
<html>
<body>
        <fieldset>
            <legend>Введите имя человека</legend>
            <form method="POST">
                <div class="inner">
                    <input type="submit" name="all" value="Получить данные о всех людях в БД">
                    <div class="input-area">
                        <label for="name">Имя:</label>
                        <input type="text" name="name" id="name">
                    </div>
                </div>
                <input type="hidden" name="check" value="1">
                <input type="submit" name="specific" value="Получить данные о люядх с данным именем">
            </form>
        </fieldset>
        <a href="in.php" style="text-align: center">Записать данные в БД</a>  
        <?php
            require_once "../reg file/login.php";
            $con = new mysqli($hn, $un, $pw, $db);
            if ($con->connect_error) die("Сбой подключения к БД.");

            mysqli_query($con, "SET NAMES 'utf8'"); 
            mysqli_query($con, "SET CHARACTER SET 'utf8'");
            mysqli_query($con, "SET SESSION collation_connection = 'utf8_general_ci'");

            if (isset($_POST["check"])) {
                if (empty($_POST["name"])) {
                    die("Вы не ввели имя");
                }

                if (!empty($_POST["all"])) {
                    $stmt = $con->prepare("SELECT * FROM people");
                    if (!$stmt->excecute()) die("Fatal Error");
                    $result = $stmt->get_result();
                    echo "<h1>Данные о всех людях в БД:</h1>";
                }
                if (!empty($_POST["specific"])) {
                    $name = htmlentities($_POST["name"]);
                    $stmt = $con->prepare("SELECT * FROM people WHERE name=?");
                    $stmt->bind_param("s", $name);                
                    $stmt->execute();
                    $result = $stmt->get_result();

                    if ($stmt->affected_rows == 0) die("Людей с именем " . $name . " нет в базе");

                    echo "<h1>Данные о людях с именем $name:</h1>";

                }
                foreach ($result as $row) {
                    echo "Возраст: " . $row["age"] . "<br>";
                    echo "Пол: " . ($row["gender"] == "male" ? "Мужской" : "Женский");
                }
                $stmt->close();

            }

            $con->close();

        ?>

    </body>
</html>

我想了解按下了哪个按钮。
我检查条件:

if (!empty($_POST["all"])) {
                    $stmt = $con->prepare("SELECT * FROM people");
                    if (!$stmt->excecute()) die("Fatal Error");
                    $result = $stmt->get_result();
                    echo "<h1>Данные о всех людях в БД:</h1>";
                }
                if (!empty($_POST["specific"])) {
                    $name = htmlentities($_POST["name"]);
                    $stmt = $con->prepare("SELECT * FROM people WHERE name=?");
                    $stmt->bind_param("s", $name);                
                    $stmt->execute();
                    $result = $stmt->get_result();

                    if ($stmt->affected_rows == 0) die("Людей с именем " . $name . " нет в базе");

                    echo "<h1>Данные о людях с именем $name:</h1>";

                }

但它不起作用:无论我按下哪个按钮,只有第二个有效。

我如何理解仅使用 PHP / MySQL 按下了哪个按钮?

PS我在SO上看到过类似的问题,但我没有找到我的问题的答案

php
  • 3 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-12-30 21:57:46 +0000 UTC

在这种情况下我应该使用 get_magic_quotes_gpc() 吗?

  • 0

在我的书(使用 PHP、MySQL、JavaScript、CSS 和 HTML5 构建动态网站)中,有一个示例说明如何在用户输入的数据进入数据库之前对其进行处理。

function mysql_fix_string($conn, $string) {
   if (get_magic_quotes_gpc()) $string = stripslashes($string);
   return $conn->real_escape_string($string);
}

根据作者的说法,get_magic_quotes_gpc() 检查是否启用了在字符串中转义引号的“魔术引号”属性。如果函数返回 TRUE,则触发 stripslashes 函数,该函数从字符串中删除斜杠(删除转义),以便 real_escape_string() 不会两次转义引号。
但是文档说 get_magic_quotes_gpc() 自 PHP 5.4.0 以来已被弃用。并且总是返回 FALSE。并且作者自己说,从 PHP 5.4.0 起,自动转义单引号和双引号的 magic_quotes 属性已被删除。

使用 get_magic_quotes_gpc() 有意义吗?

php
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-12-08 22:53:19 +0000 UTC

如何创建一个 Radiobutton 数组?

  • 0

有一个表格。上面有 4 个单选按钮。
我正在尝试创建一个数组:

Dim radioButtons As RadioButton {
 RadioButton1,
 RadioButton2,
 RadioButton3,
 RadioButton4
}

然后我尝试在循环中迭代数组:

For i = 0 To ubound(radiobuttons)
   radioButtons(i).Text = ...
Next

但是在循环中,会发生错误。
如何正确实施这个想法?

vb.net
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-12-05 23:01:16 +0000 UTC

为什么 Ord() 函数不起作用?

  • 0
Function getNumOfSym(ch As Char)
        Return ord(ch)
    End Function

VB不知道这样的功能,虽然我以前用过。问题是什么?

функции
  • 1 个回答
  • 10 Views
Martin Hope
JustLearn
Asked: 2020-11-20 17:54:01 +0000 UTC

为什么在某些情况下需要指定 cin.exceptions() 方法进行异常处理,而在其他情况下不需要?

  • 1

除非指定 cin.exceptions() 否则不会捕获异常的情况:
...

cin.exceptions(istream::failbit | istream::badbit);
cout << "Вводите резльтаты игры в гольф (введите не число, если хотите закончить):\n";
int num;
bool finish = false;
for (int i = 0; i < 10; i++) {
    cout << "Введите результат № " << i + 1 << ": ";
    try {
        cin >> num;
    }
    catch (istream::failure e) { //БЕЗ cin.exceptions() НЕ СРАБОТАЕТ
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        cout << "Ввод прекращен.\n";
        break;
    }
    arr.push_back(num);
}

...

但是在另一个程序中,没有 cin.exceptions() 一切都会正常工作:(
来自 cplusplus.com 的示例:[ http://www.cplusplus.com/reference/exception/exception/?kw=exception ])

// exception example
#include <iostream>       // std::cerr
#include <typeinfo>       // operator typeid
#include <exception>      // std::exception

class Polymorphic {virtual void member(){}};

int main () {
  try
  {
    Polymorphic * pb = 0;
    typeid(*pb);  // throws a bad_typeid exception
  }
  catch (std::exception& e)
  {
    std::cerr << "exception caught: " << e.what() << '\n';
  }
  return 0;
}

为什么在某些情况下需要将参数传递给 cin.exceptions() 函数,而在其他情况下则不需要?你怎么知道什么时候需要,什么时候不需要?

c++
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5