脚本不会工作,我找不到任何错误请帮助 [英] the script wont work and i cant find anything wrong please help

查看:50
本文介绍了脚本不会工作,我找不到任何错误请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧所以脚本非常简单,它会重新发送帖子的

id,它可以让你很好地编辑它。不需要它。


现在,如果你去 www.kirewire.com/pp2/index/ php 你会看到一个数字1

这是collumn home_id的值,它被设置为自动增量等等

ect


但是这个脚本获取了一行home_id的id并允许你编辑

它对某些原因不起作用...

if(isset($ _POST [''submit''])){//处理表单。


//定义查询。

$ query =" UPDATE home SET header =''{$ _ POST [''header'']}'',

body =''{$ _ POST [''body'']}''WHERE home_id = {$ _ POST [''id'']}" ;;

$ r = mysql_query($ query); //执行查询。


//报告结果。

if(mysql_affected_rows()== 1){

打印''< p>博客条目已更新。< / p>'';

}其他{

打印"< p>可以更新条目,因为:< b>" 。 mysql_error()。

"< / b>。查询是$ query。< / p>" ;;

}


} else {//在表单中显示条目。


//检查URL中的有效条目ID。

if(is_numeric($ _GET [''id''])){
< br $>
//定义查询。

$ query =" SELECT * FROM home_id WHERE home_id = {$ _ GET [''id'']}" ;;

if($ r = mysql_query($ query)){//运行查询。


$ row = mysql_fetch_array($ r); //检索信息。


//制作表格。

print''< form action =" update_site.php" method =" post">

< p>标题:< input type =" text"名称= QUOT;报头QUOT;大小= QUOT; 40" maxsize =" 100"

value ="''。 $ row [''header'']。 " />< / p>

< p>正文:< textarea name =" body"列= QUOT; 40" rows =" 5">''。 $ row [''body'']

..''< / textarea>< / p>

< input type =" hidden"名称= QUOT; ID" value ="''。 $ _GET [''id'']。 " />

< input type =" submit"命名= [提交" value ="更新您的网站! />

< / form>'';


} else {//无法获取信息。

print"< p>可以检索条目,因为:< b>" 。 mysql_error()。

"< / b>。查询是$ query。< / p>" ;;

}


}其他{//没有设置ID。

print''< p>< b>您在使用此

页时一定是犯了错误。< / b>< / p>'';

}


} //主IF结束。


mysql_close(); //关闭数据库连接。


?>


查看你得到的内容 www.kirewire.com/pp2/update_site.php


你能帮忙,谢谢,并感恩节快乐

all right so the script is pretty simple it goes it retrives what the
id of the post is and it lets you edit it well no it doesnt.

now if you go to www.kirewire.com/pp2/index/php you will see a number 1
that is the value of collumn home_id which is set to auto increment ect
ect

but this script which gets the id of home_id of a row and lets you edit
it does not work for somereason...
if (isset ($_POST[''submit''])) { // Handle the form.

// Define the query.
$query = "UPDATE home SET header=''{$_POST[''header'']}'',
body=''{$_POST[''body'']}'' WHERE home_id={$_POST[''id'']}";
$r = mysql_query ($query); // Execute the query.

// Report on the result.
if (mysql_affected_rows() == 1) {
print ''<p>The blog entry has been updated.</p>'';
} else {
print "<p>Could update the entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}

} else { // Display the entry in a form.

// Check for a valid entry ID in the URL.
if (is_numeric ($_GET[''id'']) ) {

// Define the query.
$query = "SELECT * FROM home_id WHERE home_id={$_GET[''id'']}";
if ($r = mysql_query ($query)) { // Run the query.

$row = mysql_fetch_array ($r); // Retrieve the information.

// Make the form.
print ''<form action="update_site.php" method="post">
<p>Header: <input type="text" name="header" size="40" maxsize="100"
value="'' . $row[''header''] . ''" /></p>
<p>Body: <textarea name="body" columns="40" rows="5">'' . $row[''body'']
.. ''</textarea></p>
<input type="hidden" name="id" value="'' . $_GET[''id''] . ''" />
<input type="submit" name="submit" value="Update your Website!" />
</form>'';

} else { // Couldn''t get the information.
print "<p>Could retrieve the entry because: <b>" . mysql_error() .
"</b>. The query was $query.</p>";
}

} else { // No ID set.
print ''<p><b>You must have made a mistake in using this
page.</b></p>'';
}

} // End of main IF.

mysql_close(); // Close the database connection.

?>

to see what you get go to www.kirewire.com/pp2/update_site.php

could you please help, thanks, and have a happy thanksgiving

推荐答案

_POST [''submit''])){//处理表单。


//定义查询。
_POST[''submit''])) { // Handle the form.

// Define the query.


query =" UPDATE home SET header =''{
query = "UPDATE home SET header=''{


_POST [''header'']}'',

body =''{
_POST[''header'']}'',
body=''{


这篇关于脚本不会工作,我找不到任何错误请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆