mysql add script
From: n_200th (n_200th_at_yahoo.com)
Date: 10/29/03
- Next message: Robert K S: "Why does imageftbbox give anomalous values when first called?"
- Previous message: David Otton: "Re: [PHP] Echo issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2003 03:28:23 -0800
all, i am trying to follow this example from 'CREATE DYNAMIC WEBPAGES
USING PHP & MYSQL BY DAVID TANSLEY. the script listed doesnt work for
me, everytime i add a new system i receive an error:
"Error: You have either not filled in the system box OR you have
typed in an exiting system that is already in the table system";
=======================================================================
[root@localhost html]# more g_write_system.php
<HTML>
<BODY>
<?php
# g_write_system.php
# include file
include ("conn_inc.php");
include ("g_common_func.php");
header1();
title(" Add a new technical system area");
$sql="SELECT system_type FROM system WHERE system_type='$system'";
# make sure user is not adding a duplicate and field is not empty
$error=false;
if ( $system == "" ) {
$error=true;
}
# check for duplicate entry in the system table
$mysql_result=mysql_query($sql,$connection);
$num_rows=@mysql_num_rows($mysql_result);
if ( $num_rows != 0 ) {
$error=true;
}
if ($error) {
echo "Error: You have either not filled in the system box
<BR><B>OR</B> you have
typed in an exiting system that is already in the table system";
add_system_scr();
footer();
exit;
}
$sql="INSERT INTO system (system_type) VALUES ('$system')";
if (!mysql_query($sql,$connection)) {
echo "Error cannot add record..Check out MySQL";
main_menu_scr();
exit;
} else {
# insert OK inform user
echo "Table updated [".mysql_affected_rows()."] record added<BR>";
echo "The system <B>$system</B> has been added";
}
main_menu_scr();
footer();
mysql_close($connection);
?>
</BODY>
</HTML>
[root@localhost html]#
- Next message: Robert K S: "Why does imageftbbox give anomalous values when first called?"
- Previous message: David Otton: "Re: [PHP] Echo issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|