- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有点卡住了,我可以手动更新数据库,但是通过 PHP 它不起作用。
数据库字段:
Column Type Collation Attributes Null Default Extra
id int(10) UNSIGNED No auto_increment
addedby varchar(100) latin1_swedish_ci No
location text latin1_swedish_ci No
details text latin1_swedish_ci No
deadline text latin1_swedish_ci No
datefixed int(200) No 0
completed int(11) No 0
Add_jobs.php:
<?php
$pagetitle = "Add Job";
$checkrank = 3;
include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');
$helpfaerie = mysql_fetch_array(mysql_query("SELECT * FROM helpfaerie WHERE page = 'reportbug'"));
$helpfaerie2 = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE username = '$username'"));
if ($helpfaerie2[helpfaerie] == 1)
{
echo "<div id=\"helpfaerie\" style=\"overflow: auto; position:fixed; bottom:0; right:0; \"><table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; background-color:#ffffff;\">
<tr>
<td><center><img src=\"http://images.neopets.com/items/toy_faerie_psellia.gif\" border=\"0\"></center></td>
</tr>
<tr>
<td><p>$helpfaerie[text]</p></td>
</tr>
<tr>
<td style=\"text-align: right;\">[<a href=\"$baseurl/closehelp.pro.php\">x</a>]</td>
</tr>
</table></div>";
}
ECHO <<<END
<center>
<FORM ACTION="add_jobs.pro.php" enctype="multipart/form-data" METHOD=POST>
<table width="366" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><center>Add Job<p></center></td>
</tr>
<tr>
<td width="118">Job Location (If any):</td>
<td width="249"><textarea name="page" cols="20" rows="1" value="" ></textarea></td>
</tr>
<tr>
<td width="118">Details::</td>
<td width="249"><textarea name="wrong" cols="20" rows="10" value="" ></textarea></td>
</tr>
<tr>
<td width="118">Deadline::</td>
<td width="249"><textarea name="line" cols="20" rows="1" value=""></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><center><font size="-1"><i>
<input type=submit name=Submit value="Add Jobs">
</i></font></center></td>
</tr>
</table></FORM>
<p> </p></center>
END;
include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');
?>
注意:dblink(链接到我的数据库,工作正常,)插件,主要用于笑脸和语法。
基本上这是一个工作页面,我们用我们需要在网站上完成的工作更新它。
add_jobs.pro.php:
<?php
$pagetitle = "Add Jobs";
$checkrank = 3;
include ($_SERVER['DOCUMENT_ROOT'].'/addon.php');
include ($_SERVER['DOCUMENT_ROOT'].'/dblink.php');
include ($_SERVER['DOCUMENT_ROOT'].'/security/stripusers.php');
$page = $_POST['page'];
$wrong = $_POST['wrong'];
$line = $_POST['line'];
$page = mysql_real_escape_string($page);
$page = stripslashes($page);
$page = stripusers($page);
$wrong = mysql_real_escape_string($wrong);
$wrong = stripslashes($wrong);
$wrong = stripusers($wrong);
$line = mysql_real_escape_string($line);
$line = stripslashes($line);
$line = stripusers($line);
if ((!$page) OR (!$wrong) OR (!$line))
{
die(header("Location: $baseurl/add_jobs.php?error=Please+do+not+leave+any+info+blank."));
}
else
{
mysql_query("INSERT INTO assignments (addedby,location,details,deadline,datefixed) VALUES ('$username','$page','$wrong','$line','$timestamp','0')");
header("Location: add_jobs.php?error=Thank+you.+Your+Job+has+been+submitted.");
}
?>
我刚进入另一个问题。
提交工作后,他们将在此列出
<?php
$pagetitle = "Active Jobs";
$checkrank = 0;
include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');
$view=$_GET['view'];
$num = mysql_num_rows(mysql_query("SELECT * FROM `assignments` WHERE 1"));
if ($num <= 0)
{
echo "
<p><center>
There are no active jobs :D";
}
$sort = mysql_query("SELECT * FROM `assignments` WHERE 1");
while($sort2 = mysql_fetch_array($sort))
{
if($sort2[id])
{
$tym = date("H:i",$sort2[date]);
$wcd = date("M j Y",$sort2[date]);
echo("
<center>
<table width=\"607\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; \">
<tr>
<td width=\"139\" valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Submitted By:</td>
<td width=\"450\" valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[addedby]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Date Submitted:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\"> $wcd @ $tym NST</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Job Location:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[location] [<a href=\"$sort2[location]\">View</a>]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Job Description:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[details]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Deadline:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[deadline]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-right: 1pt solid black; background-color:#5eaed4;\">completed?:</td>
<td valign=\"top\" style=\"background-color:#f4f4f4;\">Click When Completed [<a href=\"$baseurl/staff/submitted/completed_job.pro.php?id=$sort2[id]\">x</a>]</td>
</tr>
</table>
<p> </p></center>
"); }
}
echo "<p></center>\n";
echo "</center>\n";
include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');
?>
然后您单击 X,然后将它们归类为已完成,这意味着将它们从页面中删除,但它并没有这样做,它们只是保持在列表中,
但他们也注册了他们的修复,并显示在完成的工作页面上。
completed_jobs.php
<?php
$pagetitle = "Active Jobs";
$checkrank = 0;
include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');
$view=$_GET['view'];
$num = mysql_num_rows(mysql_query("SELECT id FROM assignments WHERE completed =1"));
if ($num <= 0)
{
echo "
<p><center>
There are no complete Jobs at this time.";
}
$sort = mysql_query("SELECT * FROM assignments WHERE completed =1");
while($sort2 = mysql_fetch_array($sort))
{
if($sort2[id])
{
$tym = date("H:i",$sort2[date]);
$wcd = date("M j Y",$sort2[date]);
$ftym = date("H:i",$sort2[datefixed]);
$fwcd = date("M j Y",$sort2[datefixed]);
echo("
<center>
<table width=\"607\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; \">
<tr>
<td width=\"139\" valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Submitted By:</td>
<td width=\"450\" valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[addedby]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Date Submitted:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\"> $wcd @ $tym NST</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Job Location:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[location] [<a href=\"$sort2[location]\">View</a>]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Job Description:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[details]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#8cc7e3;\">Deadline:</td>
<td valign=\"top\" style=\"border-bottom: 1pt solid black;background-color:#f4f4f4;\">$sort2[deadline]</td>
</tr>
<tr>
<td valign=\"top\" style=\"border-right: 1pt solid black; background-color:#5eaed4;\">Completed On:</td>
<td valign=\"top\" style=\"background-color:#f4f4f4;\">$fwcd @ $ftym NST</td>
</tr>
</table>
<p> </p></center>
"); }
}
echo "<p></center>\n";
echo "</center>\n";
include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');
?>
and then completed_job.pro.php
<?php
$pagetitle = "Completed Jobs";
$checkrank = 30;
include ($_SERVER['DOCUMENT_ROOT'].'/addon.php');
include ($_SERVER['DOCUMENT_ROOT'].'/dblink.php');
$id=$_GET['id'];
mysql_query("UPDATE assignments SET completed = '1' WHERE id = '$id'");
mysql_query("UPDATE assignments SET datefixed = '$timestamp' WHERE id = '$id'");
header("Location: completed_jobs.php?error=Job+has+been+updated+to+complete+:)");
?>
最佳答案
不要在调用mysql_real_escape_string()
之后调用stripslashes()
! 事实上,除非magic_quotes_gpc()
打开(不推荐这样做),根本不要调用 stripslashes()
。通过在 mysql_real_escape_string()
之后调用它,您可以撤消该函数提供的转义。
您在插入列列表中指定了 5 列,但在 VALUES()
列表中提供了 6 列。根据您的表结构,我猜测您也打算包含 completed
。
mysql_query("INSERT INTO assignments (addedby,location,details,deadline,datefixed) VALUES ('$username','$page','$wrong','$line','$timestamp','0')");
//-------------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我们假设变量 $username
和 $timestamp
已经在包含的文件之一中定义并且已经正确转义。
一些错误检查会揭示查询错误的来源:
$result = mysql_query("INSERT INTO assignments (addedby,location,details,deadline,datefixed) VALUES ('$username','$page','$wrong','$line','$timestamp','0')");
if (!$result) {
echo mysql_error();
}
关于php - 将数据插入数据库不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10075443/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!