小编Nis*_*röm的帖子

如何在不更新Dreamweaver中的数据库的情况下将PHP表单数据保存到会话变量?

我正在使用Dreamweaver构建我的PHP/MySQL站点,因为我的技能相当小,我想将选项从多选项下拉列表保存到$_SESSION变量.我在前一页上使用以下内容更新数据库中的字段时成功设法保存到会话变量并且似乎正在工作(Dreamweaver插入的页面顶部,我评论了我编辑它以使其存储到的位置的$_SESSION):

<?php
if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  {
    if (PHP_VERSION < 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    switch ($theType) {
      case "text":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;    
      case "long":
      case "int":
        $theValue = ($theValue != "") ? intval($theValue) : "NULL";
        break;
      case "double":
        $theValue = ($theValue != "") ? …
Run Code Online (Sandbox Code Playgroud)

php mysql forms session post

0
推荐指数
1
解决办法
629
查看次数

在没有mysqli_real_escape_string的数据库中使用单引号保存字符串

我想在我的表列中保存字符串"thats'one",但我不想使用mysqli_real_escape_string.任何人都可以指导我如何做到这一点?

php mysql string mysqli

0
推荐指数
1
解决办法
568
查看次数

在php返回和html之间中断

我无法理解为什么"Hello 1"和"Logout"之间存在中断.谁能明白为什么?

在此输入图像描述

<h4 class="hello">Hello, <em><?php echo $_SESSION['username'];?>!</em></h4>
            <a href="logout.php" style="font-size:18px">Logout?</a>
            <a href="test.php">test</a>
        <div id="container">
            <div class="topbar">
                <p id="headline">Test</p>
                <p id="headline_1">Page</p>

            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

html css

0
推荐指数
1
解决办法
43
查看次数

访问嵌套的JSON密钥而不循环

我有一个JSON字符串,如下面给出的存储在其中的字符串$json.我想在category_id不使用循环的情况下访问第一个.我该如何访问它?

$json = '{"outfits": [{"1": [{"category_id": "women_jeans", "product_id": 464540467}, {"category_id": "women_tops", "product_id": 487351815}, {"category_id": "women_coats", "product_id": 493322686}, {"category_id": "women_bags", "product_id": 483902882}, {"category_id": "women_shoes", "product_id": 492772225}]}]}';
$outfits = json_decode($json);
Run Code Online (Sandbox Code Playgroud)

php arrays json object

0
推荐指数
1
解决办法
419
查看次数

为什么我可以分配比 RAM 更大的数组?

我在通话时面临一个奇怪的问题malloc。我正在开发一个使用巨大数组(大小以 GB 为单位)的程序,并在尝试使用malloc该数组为数组分配内存时发现,malloc即使我分配的大小大于我的 RAM(64GB),它也是成功的。

参见下面的代码:

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>


#define Sixteen_G  16000000000

int main() {
    int *c = (int *)malloc(sizeof(int)*Sixteen_G);
    int *d = (int *)malloc(sizeof(int)*Sixteen_G);
    int *e = (int *)malloc(sizeof(int)*Sixteen_G);
    int *f = (int *)malloc(sizeof(int)*Sixteen_G);
    int *g = (int *)malloc(sizeof(int)*Sixteen_G);
    if(c == NULL)
            printf("c Allocation failed\n");
    if(d == NULL)
            printf("d Allocation failed\n");
    if(e == NULL)
            printf("e Allocation failed\n");
    if(f == NULL)
            printf("e Allocation failed\n");
    if(g == NULL)
            printf("e Allocation failed\n");
    else
            printf("All arrays allocated\n");
    return …
Run Code Online (Sandbox Code Playgroud)

c memory arrays memory-management

0
推荐指数
1
解决办法
764
查看次数

如何避免重复是css?

如何避免以下CSS重复:

div#logo div:nth-child(1) div {
    width: 30%;
    height: 30%;
    background-color: white;
}

div#logo div:nth-child(3) div {
    width: 30%;
    height: 30%;
    background-color: white;
}
Run Code Online (Sandbox Code Playgroud)

html css

0
推荐指数
1
解决办法
71
查看次数

连接和查询两个列名冲突的表

想象一下我有两个表:用户学生

每个表都有一个 id 和 email 列。我希望能够从两个表中搜索电子邮件。我可以像这样连接两个 ID 匹配的表:

SELECT users.email,students.email as student_email FROM users
INNER JOIN students ON users.id = students.id
Run Code Online (Sandbox Code Playgroud)

我无法搜索电子邮件列,因为它们具有相同的列名(电子邮件)。因此,如果我尝试使用WHERE它会抱怨该列(电子邮件)不明确。如果我尝试使用student_email它会抱怨该列不存在。

如果这两个表没有使用相同的列名(电子邮件),那么当我使用WHERE.

我能想到的唯一解决方案是获取所有行,然后围绕它们循环并手动搜索电子邮件字符串。与像这样使用 MySQL 相比,这非常慢:

SELECT users.email,students.email as student_email FROM users
INNER JOIN students ON users.id = students.id
WHERE email LIKE '%test@email.com%' OR student_email LIKE '%test@email.com%'
Run Code Online (Sandbox Code Playgroud)

但当然这不起作用,因为WHERESELECT.

我怎样才能在不获取所有行和循环的情况下解决这个问题?也许它是一个联合,而不是一个JOIN? 我不知道...

mysql sql

0
推荐指数
1
解决办法
492
查看次数

为什么Go json.Marshal拒绝这些struct标签?json标签的正确语法是什么?

我正在尝试使用json.Marshal,但它拒绝接受我的struct标记。

我究竟做错了什么?

这是“ marshal.go”的源代码

https://play.golang.org/p/eFe03_89Ly9

package main

import (
    "encoding/json"
    "fmt"
)

type Person struct {
    Name string `json: "name"`
    Age  int    `json: "age"`
}

func main() {
    p := Person{Name: "Alice", Age: 29}
    bytes, _ := json.Marshal(p)
    fmt.Println("JSON = ", string(bytes))
}
Run Code Online (Sandbox Code Playgroud)

我从“ go vet marshal.go”获得这些错误消息

./marshal.go:9: struct field tag `json: "name"` not compatible with reflect.StructTag.Get: bad syntax for struct tag value
./marshal.go:10: struct field tag `json: "age"` not compatible with reflect.StructTag.Get: bad syntax for struct tag value
Run Code Online (Sandbox Code Playgroud)

我在运行程序时得到此输出。 …

tags json struct marshalling go

0
推荐指数
1
解决办法
2357
查看次数

如何修复被释放的指针未分配

我试图释放为该malloc函数分配的空间,但每次收到此消息时:

“malloc:*** 对象 0x7ffeefbff510 错误:未分配正在释放的指针”

即使我明确地将其分配为malloc().

我已经尝试过发送& manufacture并且只是manufacture。我对整个内存分配非常陌生。

char* manufacture = (char*)malloc(15*sizeof(char));   
manufacture = "Suzuki"; 

free(manufacture);
Run Code Online (Sandbox Code Playgroud)

c malloc dynamic-memory-allocation

-1
推荐指数
1
解决办法
4512
查看次数

表和链接搞乱了代码

我有PHP和链接的问题,我的意思是,我试图用来<a href链接票证的ID然后显示给用户,但问题是我得到的链接就像

HTTP://localhost/ucp/viewticket.php ticketid = 8%3Etest%3C /一%3E%3C/TD%3E%3Ctd%3EUpute%20I%20informacije%3C/TD%3E%3Ctd%3E2016-08- 26%2000:06:59%3C/TD%3E%3C/TR%3E%3Ctr%3E%3Ctd%3E9%3C/TD%3E%3Ctd%3ESale_Lesa%3C/TD%3E%3Ctd%3E%3CA% 20href =

它应该只是像

HTTP://localhost/ucp/viewticket.php ticketid = 8

这是代码:

if ($result = $con->query($query)) 
{
    echo '
    <table id="tfhover" class="tftable" border="1">
       <th>ID Tiketa</th>
        <th>Autor</th>
        <th>Naslov</th>
        <th>Kategorija</th>
        <th>Datum</th>
    ';
    while ($row = $result->fetch_assoc())
    {
        echo "<tr>";
        echo "<td>" . $row['ID'] . "</td>";
        echo "<td>" . $row['Autor'] . "</td>";
        echo "<td><a href=\"viewticket.php?ticketid=". $row['ID'] .">". $row['Naslov'] ."</a></td>";
        echo "<td>" . $row['Kategorija'] . "</td>";
        echo "<td>" . $row['Datum'] . "</td>";
        echo "</tr>";
    }
    $result->free();
}
Run Code Online (Sandbox Code Playgroud)

html php

-3
推荐指数
1
解决办法
56
查看次数

表格内的div标签 - html

这是我的HTML表格:

<div>
  <table>
    <thead>
      <tr>
        <th>Host Name</th>
        <th>OS Name</th>
        <th>OS Architecture</th>
      </tr>
    </thead>
    <tbody>
      <div id = "tttt">
        <tr>
          <td>a</td>
          <td>b</td>
          <td>c</td>
        </tr>
      </div>
    </tbody>
  </table>
</div>
Run Code Online (Sandbox Code Playgroud)

当我查找view sourceHTML时,<div>标签似乎已经转移到了表格之上.知道为什么会这样吗?我div在那个地方使用,因为我想通过javascript填充记录.

html

-5
推荐指数
1
解决办法
447
查看次数

* arr []是什么意思?

我有上次考试中的这段代码,这是我第一次看到此代码*arr[]。这意味着什么?它是矩阵还是数组?它包含什么?

#include <stdio.h>
void f2(int **a, int x, int y);
int main()
{
  int m[3][4] = {{7,12,11,21 }, {20,1,2,3}, {33,42,11,50}};
  int *arr[] = { m[0], m[1], m[2] };
  f2(arr, 3, 4);
  _getch();
  return 0;
}

void f2(int **a, int x, int y)
{
  if (x > 0)
  {
    int i, j = 0, *p = a[x - 1];
    for (i = 0; i < y; i++)
    {
      if (!(p[i] % 3))
        printf("%d ", p[i]);
    }
    f2(a, x - …
Run Code Online (Sandbox Code Playgroud)

c arrays matrix

-6
推荐指数
1
解决办法
5591
查看次数