我无法访问文本框内容以在Mysql中创建表,并且错误是 “创建表时出错:表名称错误”
<?php
$conn=mysqli_connect("localhost","root","","abc");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$email = isset($_POST['email']) ? $_POST['email'] : '';
// sql to create table
$sql = "CREATE TABLE `$email` (
`id` INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`firstname` VARCHAR(30) NOT NULL,
`lastname` VARCHAR(30) NOT NULL,
`email` VARCHAR(50),
`regdate` TIMESTAMP
)";
if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
答案 0 :(得分:1)
如果错误为“错误创建表:错误的表名”,并且您查询的内容为:
CREATE TABLE `$email`
很可能$email
上有一个@
符号,它不应该是表格名称的一部分-请仅使用[0-9,az,AZ $ _](基本拉丁字母,数字0-9,美元,下划线)。
每次升华时都不太可能创建一个表,并且它的名称应该是动态的(您将不知道要从该表中查询数据)。
同样重要-切勿在SQL中直接使用用户输入(以避免SQL注入)。参考: PHP MySQLi Prepared Statements Tutorial to Prevent SQL Injection
答案 1 :(得分:1)
您可以尝试以下操作-
library(shiny)
library(shinydashboard)
# UI ----------------------------------------------------------------------
ui = fluidPage(
tagList(
box(
width = 5,
tags$div(style = "display:inline-block; width:75%;",
fileInput(
inputId = 'file',
label = 'Select file:',
accept = c('.txt', '.csv', '.xls', '.xlsx', '.rds', '.dta', '.sas7bdat', '.sav')
)
),
tags$div(style = "display:inline-block; width:20%;",
div(class = 'pull-right',
actionButton('upload', 'Upload')
)
)
)
)
)
# SERVER ------------------------------------------------------------------
server <- shinyServer(function(input, output, session) {})
shinyApp(ui, server)