PHP:逃避特殊包机或更换它们

时间:2016-05-17 08:55:10

标签: php sql mysqli

我想逃避在数据库中提取的特殊字符,并希望用apostrohpe标志替换它,这就是我查询数据库的方式

  #include <stdio.h>
#include <malloc.h>
#include "ca.h"

#define wrong_input "Chybny vstup.\n"

int *bubbleSort(int *arrayWithValues, int *helpArr, int size);

void free2DArray(int **array, int numOfRows);

int main() {
    int zeroOnLine;
    int zeroCounter = 0;
    short numOfColors;
    long long numOfAutomaton;
    scanf("%hd", &numOfColors);
    switch (numOfColors) {
        case 2:
            numOfAutomaton = 256;
            break;
        case 3:
            numOfAutomaton = 7625597484987;
            break;
        default:
            printf(wrong_input);
            return 100;
    }

    long long rule;
    scanf("%lld", &rule);

    if (rule < 0 || rule >= numOfAutomaton) {
        printf(wrong_input);
        return 101;
    }
    int numOfSteps;
    scanf("%d", &numOfSteps);
    if (numOfSteps < 1) {
        printf(wrong_input);
        return 102;
    }
    int inputLength;
    scanf("%d", &inputLength);
    if (inputLength <= 0) {
        printf(wrong_input);
        return 103;
    }
    int i;
    int **result = (int **) calloc((numOfSteps + 1), sizeof(int *));
    for (int row = 0; row < numOfSteps + 1; row++) {
        result[row] = (int *) calloc(inputLength, sizeof(int));//LINE 55-Problem is there:)
    }
    for (i = 0; i < inputLength; i++) {
        scanf("%d", &result[0][i]);

    if (result[0][i] > (numOfColors - 1) || result[0][i] < 0) {
        printf(wrong_input);
        return 104;
    }
}
ca_cfg_t *ca = ca_init(numOfColors, rule);


int *zeroArr = calloc(numOfSteps + 1, sizeof(int));
zeroOnLine = 0;
for (int j = 0; j < inputLength; j++) {
    if (result[0][j] == 0) {
        printf(".");
        zeroOnLine++;
    } else {
        printf("%d", result[0][j]);
    }
}
zeroArr[0] = zeroOnLine;
zeroCounter += zeroOnLine;
printf("\n");
for (int row = 1; row < numOfSteps + 1; row++) {
    zeroOnLine = 0;
    result[row] = ca_step(ca, result[row - 1], inputLength);
    for (int column = 0; column < inputLength; column++) {
        if (result[row][column] == 0) {
            printf(".");
            zeroOnLine++;
            } else {
                printf("%d", result[row][column]);
            }
        }
        zeroArr[row] = zeroOnLine;
        zeroCounter += zeroOnLine;
        printf("\n");
    }
    printf("Celkovy pocet nul je %d\n", zeroCounter);
    int *helpArr = calloc(numOfSteps + 1, sizeof(int));
    for (int i = 0; i < numOfSteps + 1; ++i) {
        helpArr[i] = i;
    }
    helpArr = bubbleSort(zeroArr, helpArr, (numOfSteps + 1));
    int sortedRow;
    for (int row = 0; row < numOfSteps + 1; row++) {
        sortedRow = helpArr[row];
        for (int column = 0; column < inputLength; column++) {
            if (result[sortedRow][column] == 0) {
                printf(".");
            } else {
                printf("%d", result[sortedRow][column]);
            }
        }
        printf("\n");
    }
    free(helpArr);
    free(zeroArr);
    free2DArray(result, numOfSteps + 1);
    ca_done(ca);
    return 0;
}

void free2DArray(int **array, int numOfRows) {
    for (int row = 0; row < numOfRows; row++)
        free(array[row]);
    free(array);
}

int *bubbleSort(int *arrayWithValues, int *helpArr, int size) {
    for (int i = 0; i < size - 1; i++) {
        for (int j = 0; j < size - i - 1; j++) {
            if (arrayWithValues[helpArr[j + 1]] > arrayWithValues[helpArr[j]]) {
                int tmp = helpArr[j + 1];
                helpArr[j + 1] = helpArr[j];
                helpArr[j] = tmp;
            }
        }
    }
    return helpArr;
}

但问题是我得到这样的输出

  

课程将包括�类型

如何将它们转义或转换为另一个角色

0 个答案:

没有答案