通过 php 更新 mySQL 后需要帮助创建自定义成功和失败页面
如何更改我的脚本,以便成功的更新将自动将我带到网页,而错误将把我带到失败的网页?
我想要两个不同的网页代表成功或失败。
感谢您的帮助。
埃里克
<?PHP
session_start();
?>
<?php
$type=$_POST['type'];
$part_no=$_POST['part_no'];
$description=$_POST['description'];
$count=$_POST['count'];
$min=$_POST['min'];
$max=$_POST['max'];
$db="naturan8_hero";
$link = mysql_connect("localhost", "XXXXXX", "XXXXXX");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query(" UPDATE cartons_current SET type='$type' , description='$description' ,
count='$count' , min='$min' , max='$max' WHERE part_no='$part_no'");
echo "Record Updated";
mysql_close($link);
?>
How do I change my script so that a successful update will automatically take me to a web page and an error will take me to a fail web page?
I would like to have two different web pages representing success or failure.
Thank you for your help.
Erik
<?PHP
session_start();
?>
<?php
$type=$_POST['type'];
$part_no=$_POST['part_no'];
$description=$_POST['description'];
$count=$_POST['count'];
$min=$_POST['min'];
$max=$_POST['max'];
$db="naturan8_hero";
$link = mysql_connect("localhost", "XXXXXX", "XXXXXX");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query(" UPDATE cartons_current SET type='$type' , description='$description' ,
count='$count' , min='$min' , max='$max' WHERE part_no='$part_no'");
echo "Record Updated";
mysql_close($link);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单如 ABC - 替换
为:
mysql_query()
(...) 对于其他类型的 SQL 语句,INSERT、UPDATE、DELETE、DROP 等,mysql_query() 在成功时返回 TRUE,在错误时返回 FALSE。
mysql_affected_rows() - 获取最后受影响的行数INSERT、UPDATE、REPLACE 或 DELETE 查询
simple as ABC - replace
with:
mysql_query()
(...) For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
mysql_affected_rows() - Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query