PHP代码不适用于我的数据库
除了实际图像本身,数据库中的所有内容都在填充。我已经看了好几个小时了,我似乎不明白为什么在我点击提交时仍然会出现这些错误。虽然我从其他信息中得到了错误;大小、类型、名称都会显示在我的数据库中。请帮忙。这是我的密码PHP代码不适用于我的数据库,php,html,Php,Html,除了实际图像本身,数据库中的所有内容都在填充。我已经看了好几个小时了,我似乎不明白为什么在我点击提交时仍然会出现这些错误。虽然我从其他信息中得到了错误;大小、类型、名称都会显示在我的数据库中。请帮忙。这是我的密码 <?php ob_start(); ?> <?php session_start(); if($_SESSION['nachos'] != "admin") header("Location: index.php"); ?> <html
<?php
ob_start();
?>
<?php
session_start();
if($_SESSION['nachos'] != "admin")
header("Location: index.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Steven Eck - Portfolio Form</title>
<style type="text/css">
.auto-style1 {
font-family: "Courier New", Courier, monospace;
font-size: x-large;
font-weight: bold;
}
.auto-style2 {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
font-size: medium;
}
.auto-style3 {
font-family: "Courier New", Courier, monospace;
font-size: small;
text-decoration: blink;
}
</style>
</head>
<body style="color: #00FF00; background-color: #000000">
<div id="contentWrapper">
<div id="mainContent">
<?php
//display form if user has not clicked submit
if (!('POST' == $_SERVER['REQUEST_METHOD']))
{
?>
<form enctype="multipart/form-data" action="portfolioForm.php" method="post">
<fieldset>
<legend class="auto-style1">Project Information</legend>
<p><label for="txtTitle"><span class="auto-style2">Title</span>:</label>
<input type="text" name="txtTitle" id="txtTitle" ></p>
<p><span class="auto-style2"><label for="txtShortDescription">Short Description:</label></span>
<input type="text" name="txtShortDescription" id="txtShortDescription" ></p>
<p><span class="auto-style2"><label for="txtLongDescription">Long Description:</label></span>
<input type="text" name="txtLongDescription"id="txtLongDescription" ></p>
<p>
<input type="file" name="imgPhoto" id="imgPhoto" ></p>
<button type="submit">Submit</button>
<br><br><span class="auto-style3"><a href="index.php">Admin
Login</a></span><br class="auto-style3"><span class="auto-style3">
<a href="portfolioForm.php">Portfolio Form</a></span><br class="auto-style3">
<span class="auto-style3">
<a href="http://www.stevesays.net/newsite.php">Main Site</a></span><br>
<br><br><br><br><br>
</fieldset>
</form>
<?php
}
//the user has submitted the form
else
{
echo "<form><fieldset><legend>Project Information</legend>";
$dbConnection = mysqli_connect("lo***host", "we***stu_st***ck1", "r******aster", "w******u_351");
if(mysqli_connect_errno()){
echo '<p style="color: red;"> Failed to connect to MySql!: ' .mysqli_connect_error() . '</p>';
}
else
echo 'connected';
$handle = fopen($_FILES['imgPhoto']['tmpName'], "r");
$image = fread($handle, filesize($_FILES['imgPhoto']['tmpName']));
fclose($handle);
$image = mysqli_real_escape_string($dbConnection, $image);
mysqli_query($dbConnection, "INSERT INTO portfolio (title, shortDescription, longDescription, image, imageName, imageType, imageSize) VALUES ('$_POST[txtTitle]', '$_POST[txtShortDescription]', '$_POST[txtLongDescription]', '$image', '" . $_FILES['imgPhoto']['name']. " ', ' " . $_FILES['imgPhoto']['type']. " ', '" . $_FILES['imgPhoto']['size']. "' )");
echo "<p style=\"text-align: center; font-size: 11px;\">Thanks for filling out form!</p>";
echo "</fieldset></form>" ;
}
?>
</div>
史蒂文·埃克-投资组合表格
.auto-style1{
字体系列:“Courier New”,Courier,monospace;
字号:x大号;
字体大小:粗体;
}
.auto-style2{
字体系列:“Courier New”,Courier,monospace;
字体大小:粗体;
字号:中等;
}
.自动样式3{
字体系列:“Courier New”,Courier,monospace;
字体大小:小;
文字装饰:闪烁;
}
项目信息
标题:
简要说明:
详细说明:
提交
键入错误tmpName
=>tmp\u name
$handle = fopen($_FILES['imgPhoto']['tmp_name'], "r");
$image = fread($handle, filesize($_FILES['imgPhoto']['tmp_name']));
键入错误tmpName
=>tmp\u name
$handle = fopen($_FILES['imgPhoto']['tmp_name'], "r");
$image = fread($handle, filesize($_FILES['imgPhoto']['tmp_name']));
错误很明显:$\u文件['imgPhoto']['tmpName']在中为空
$handle = fopen($_FILES['imgPhoto']['tmpName'], "r");
错误很明显:$\u文件['imgPhoto']['tmpName']在中为空
$handle = fopen($_FILES['imgPhoto']['tmpName'], "r");
只是添加了它们,对不起,只是添加了它们,对不起,我真的很讨厌这种下划线。谢谢million@StevenEck你很好,我真的很讨厌像下划线这样的东西。谢谢million@StevenEck你来了