mysql add script

From: n_200th (n_200th_at_yahoo.com)
Date: 10/29/03


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]#



Relevant Pages

  • Re: question about playlist
    ... I have a dynamic playlist, playlist_1.asx, created by a php script from a ... the mysql table contain information about: ... movie near to the playing movie, and when change the movie, contextually ... Change the information in the *database* table, or in the HTML table? ...
    (microsoft.public.windowsmedia.server)
  • Re: Problems Creating the Code to Open Images Within a Template PHP Page
    ... ste wrote: ... I'm just beginning to learn PHP and MySQL, ... What I want to do is, from a HTML gallery of thumbnails, be able to open a larger version of each thumbnail image in a nice pretty formatted HTML page. ...
    (comp.lang.php)
  • Re: [PHP] HTML pages are faster then php?
    ... [PHP] HTML pages are faster then php? ... as far as I know html page will download faster then the same page made with php getting the same info from mysql, ...
    (php.general)
  • Re: Umfrage zur Fahrradnutzung - jetzt auch online
    ... als PDF macht, wo doch HTML, PHP, mySQL und Co. existieren. ...
    (de.rec.fahrrad)
  • Re: Radio Buttons
    ... the html form and the .php file. ... $resultColor = Blue; ...
    (alt.php)