我无法将数据存储在MySQL数据库中。 url1数据 - >不会转发到u1.php。无法将数据值存储到数据库
我无法解决这个问题。虽然上运行u1.php这个查询与虚拟阀它是完美的:
mysql_query("UPDATE admins SET url1 = '1234568' WHERE id = '1'");
当我检查的DB它是完美的上述价值,但是当我尝试表单数据为url1不工作。
<form action="u1.php" method="post" enctype="multipart/form-data">
<label for="file">Select The File:</label>
<input type="file" name="file" id="file">
Enter Ad Url :<input type="text" name="url1" id="url1" placeholder="Please Enter Ad Url" width: 500px;> <br><br>
<input type="submit" name="submit" value="Submit">
</form>
u1.php文件
<?php
mysql_connect("localhost","root","");
mysql_select_db("apphp");
mysql_query("UPDATE admins SET url1 = '$url1' WHERE id = '1'");
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 350000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"]/1024) . " kB<br>";
move_uploaded_file($_FILES["file"]["tmp_name"], "images/h1.jpg");
echo "Stored in: " . "images/" . $_FILES["file"]["name"];
}
}
else
{
echo "Invalid file";
}
?>
*“不工作” *并没有真正告诉我们什么,没准MySQL是抛出一个错误,你应该使用'mysql_error()'如果'的mysql_query()'不会返回成功。 – Olipro
你没有设置'$ url1'。 – Barmar