无法获取更新以使用此脚本 [英] Can't get Update to work on this script

查看:50
本文介绍了无法获取更新以使用此脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整天都在制作这个剧本而根本没有运气。我必须成功测试此脚本的两个部分才能完成此项目。我还没有测试删除部分,因为我无法让更新部分工作。我只是不知道为什么这不会更新数据库。


[PHP]<?php

include(" includes / dbconnect .PHP");


if(!isset($ cmd))

{

$ result = mysql_query(" select * from $ table)按标题排序);

while($ r = mysql_fetch_array($ result))

{


$ id = $ r [" id" ]。

$ title = stripslashes($ r [" title"]);


echo


< tr>

< td width =''20%''align =''right''> ID#:< / td>

< td> $ id< / td>

< / tr>

< tr>

< td width =''20%''align =''right''>图片标题:< / td>

< td> $ title< / td>

< / tr>

< tr>

< td width =''20%''align =''right''>图片文件名:< / td>

< td> $ image_name< / td>

< / tr>

< tr>

< td width =''20%''align =''right''> [< a href =''edit_picture.php?cmd = edit& id = $ id'' >编辑< / A> ] LT; / TD>

< td> [< a href =''edit_picture.php?cmd = delete& id = $ id''>删除< / a> ] LT; / TD>

< / tr>

< tr>< td colspan =''4''width ='''100%''style =''border-top:1px solid#666''>& nbsp; < / TD>< / TR>


" ;;


}

}

?>


< / table>


<?php


echo"< h3>编辑图片< / h3>" ;;

if($ _ GET [" cmd"] ==" edit" || $ _POST [" cmd"] ==" edit")

{

if(!isset($ _ POST [" submit"]))

{

$ id = $ _GET [" id" ]。

$ sql =" SELECT * FROM $ table WHERE id = $ id" ;;

$ result = mysql_query($ sql);

$ myrow = mysql_fetch_array($ result);

?>


< center>

< table width =" 95%" CELLSPACING = QUOT; 0" CELLPADDING = QUOT; 3英寸边界=" 0">

< tr>< td>

< form action =" edit_picture.php"方法= QUOT;交">


< input type =" hidden"名称= QUOT; ID" value ="<?php echo $ myrow [''id'']?>">



图片标题:< br>

< input type =" text"名称= QUOT;标题" VALUE ="<?php echo stripslashes($ myrow [''title''])?>"大小= QUOT; 55"><峰; br><峰; br>


图片描述:< br>

< TEXTAREA name =" desc" ROWS = 2 COLS = 70 wrap = virtual><?php echo stripslashes($ myrow [''desc''])?>< / TEXTAREA>< br>< br>


< input type =" hidden"名称= QUOT; CMD"值= QUOT;编辑">

< input type =" submit"命名= [提交"值= [提交">

< / form>

< / td>

< / tr>

< / table>

< / center>


<?php

}

?>


<?php


if($ _POST [" $ submit"])

{


$ title = addslashes($ _ POST [''title'']);

$ desc = addslashes($ _ POST [''desc'']);


$ sql =" UPDATE $ table SET title =''$ title'',desc =''$ desc''WHERE id = $ id" ;;


$ result = mysql_query($ sql);

echo"< br>< br>< p align =''center''>< span style =''color:red''>信息已更新。< / span>< br>< br>< a href =''edit_picture.php''>编辑另一张图片< / a>< / p>" ;;


}

}


?>


<?php

if($ _ GET [" cmd"] ==" delete")

{


$ image_name = $ _GET [" image_name"];


$ photo_dir =(''/ mysite.com/gallery/image_uploads/'');

$ thumb_dir =(''/ mysite.com/gallery/thumb_uploads/'');


unlink($ photo_dir。$ image_name);

unlink($ thumb_dir。$ image_name);


$ sql =" DELETE FROM $ table WHERE image_name = $ image_name" ;;

$ result = mysql_query($ sql);


echo"< br>< br>< p align =''center''>< span style =''color:red''>< ; b>图片已被删除!< br>< br>" ;;

}


?> [/ PHP]

I''ve been working on this script all day with no luck at all. I have to successfully test both parts of this script in order to finish this project. I haven''t tested the delete part yet, because I can''t get the update part to work. I just can''t figure out why this will not update the database.

[PHP]<?php
include("includes/dbconnect.php");

if(!isset($cmd))
{
$result = mysql_query("select * from $table order by title");
while($r = mysql_fetch_array($result))
{

$id = $r["id"];
$title = stripslashes($r["title"]);

echo "

<tr>
<td width=''20%'' align=''right''>ID#: </td>
<td>$id</td>
</tr>
<tr>
<td width=''20%'' align=''right''>Picture Title: </td>
<td>$title</td>
</tr>
<tr>
<td width=''20%'' align=''right''>Picture File Name: </td>
<td>$image_name</td>
</tr>
<tr>
<td width=''20%'' align=''right''>[ <a href=''edit_picture.php?cmd=edit&id=$id''>Edit</a> ]</td>
<td>[ <a href=''edit_picture.php?cmd=delete&id=$id''>Delete</a> ]</td>
</tr>
<tr><td colspan=''4'' width=''100%'' style=''border-top: 1px solid #666''>&nbsp;</td></tr>

";

}
}
?>

</table>

<?php

echo "<h3>Edit a Picture</h3>";
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM $table WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>

<center>
<table width="95%" cellspacing="0" cellpadding="3" border="0">
<tr><td>
<form action="edit_picture.php" method="post">

<input type="hidden" name="id" value="<?php echo $myrow[''id''] ?>">


Picture Title:<br>
<input type="text" name="title" VALUE="<?php echo stripslashes($myrow[''title'']) ?>" size="55"><br><br>

Picture Description:<br>
<TEXTAREA name="desc" ROWS=2 COLS=70 wrap=virtual><?php echo stripslashes($myrow[''desc'']) ?></TEXTAREA><br><br>

<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>
</td>
</tr>
</table>
</center>

<?php
}
?>

<?php

if ($_POST["$submit"])
{

$title = addslashes($_POST[''title'']);
$desc = addslashes($_POST[''desc'']);

$sql = "UPDATE $table SET title=''$title'', desc=''$desc'' WHERE id=$id";

$result = mysql_query($sql);
echo "<br><br><p align=''center''><span style=''color:red''>Information updated.</span><br><br><a href=''edit_picture.php''>Edit another Picture</a></p>";

}
}

?>

<?php
if($_GET["cmd"]=="delete")
{

$image_name = $_GET["image_name"];

$photo_dir = (''/mysite.com/gallery/image_uploads/'');
$thumb_dir = (''/mysite.com/gallery/thumb_uploads/'');

unlink($photo_dir.$image_name);
unlink($thumb_dir.$image_name);

$sql = "DELETE FROM $table WHERE image_name=$image_name";
$result = mysql_query($sql);

echo "<br><br><p align=''center''><span style=''color:red''><b>The Picture has been Deleted!<br><br>";
}

?>[/PHP]

推荐答案

cmd))

{
cmd))
{


result = mysql_query(" select * from
result = mysql_query("select * from


table order by title");

while(
table order by title");
while(


这篇关于无法获取更新以使用此脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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