问题描述
在从网页更新我的数据库时,通过
提交表单时出现问题。有人可以帮忙吗?
----这是我的代码在update.php ----(用户,通行证和数据库是
输入直接,我为了安全原因在这里更改了它们:))
<?php
/ * ---连接数据库 - - * /
$ conn = mysql_connect(" localhost"," user"," pass")或
die(mysql_error()) ;
mysql_select_db(" database",$ conn)或die(mysql_error());
$ event = $ _GET [" id"] ;
$ title = $ _ POST [''title''];
$ date = $ _ POST [''datetime''];
$ desc = $ _ POST [''desc''];
// ---在数据库中更新进入---
$ query =" ;更新''calendar_events''SET''event_title''=''$ title'',
''vent_start''=''$ date'',''event_shortdesc''='' $ desc''WHERE''id''=
$ event" ;;
//列表项目
echo" $ event $ title $ date $ desc";
mysql_query($ query);
echo" Record Updated" ;;
mysql_close();
?>
----------- ------------这是
输出-------------------------- -----------
TEST已更改2006-02-22 06:00:00 TESTING EDITINGRecord更新
-------- -------------------------------------------------- ----------------------------------
原始信息为TEST 2006 -02-22 06:00:00测试编辑"
我改变了TEST到TEST改变了在之前的
页面的提交表格中。
我收到回音,看看我的信息是否真的过去了,
它是。我从
传递了提交表单所在的上一页的id,title,event_start和event_shortdesc。为什么我的
数据库条目(行)更新?请帮忙。
Having a problem updating my database from a web page, through a
submission form. Can anyone help?
----THIS IS MY CODE IN update.php----(user, pass, and database are
typed in directly, I changed them here for securiy reasons :) )
<?php
/*---CONNECT TO DATABASE---*/
$conn = mysql_connect("localhost", "user", "pass") or
die(mysql_error());
mysql_select_db("database",$conn) or die(mysql_error());
$event = $_GET["id"];
$title=$_POST[''title''];
$date=$_POST[''datetime''];
$desc=$_POST[''desc''];
//---UPDATE ENTRY IN DATABASE---
$query = "UPDATE ''calendar_events'' SET ''event_title'' = ''$title'',
''event_start'' = ''$date'', ''event_shortdesc'' = ''$desc'' WHERE ''id'' =
$event";
//LIST ITEMS
echo "$event $title $date $desc";
mysql_query($query);
echo "Record Updated";
mysql_close();
?>
-----------------------THIS IS THE
OUTPUT-------------------------------------
TEST changed 2006-02-22 06:00:00 TESTING EDITINGRecord Updated
--------------------------------------------------------------------------------------------
The original information was "TEST 2006-02-22 06:00:00 TESTING EDITING"
I changed "TEST" to "TEST changed" in the submit form on a previous
page.
I included the echo to see if my information was truly getting passed,
it is. I passed the id, title, event_start, and event_shortdesc from
the previous page where the submission form is located. Why isn''t my
database entry (row) updating? Please help.
推荐答案
这篇关于查询和更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!