/[libdata]/branches/paul/admin/include/insert.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/paul/admin/include/insert.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 66 by dpavlin, Fri Dec 5 18:40:01 2003 UTC revision 67 by dpavlin, Thu Mar 18 19:24:54 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**********************************************************  /**********************************************************
3  Function Library: insert.php  Function Library: insert.php
4  Original Author: Paul Bramscher <brams006@tc.umn.edu>  Original Author: Paul Bramscher <brams006@umn.edu>
5  Last Modified: 09.30.2003 by Paul Bramscher  Last Modified: 03.15.2004 by Paul Bramscher
6  ***********************************************************  ***********************************************************
7  Comments:  Comments:
8  This library brings together all SQL insert functions for  This library brings together all SQL insert functions for
9  LibData general setup tables.  Those pertaining to  LibData general setup tables.  Those pertaining to
10  CLPS and RQS are located in scribe_application.php and  PageScribe and SubjectBuilder are located in
11  subject_builder.php respectively.  scribe_application.php and subject_builder.php
12    respectively.
13  ***********************************************************  ***********************************************************
14  Table of Contents:  Table of Contents:
   
15  insertCoursesub  insertCoursesub
16  insertFaculty  insertFaculty
17  insertFeature  insertFeature
# Line 24  insertSingleField Line 24  insertSingleField
24  insertStaff  insertStaff
25  insertStyle  insertStyle
26  insertSubject  insertSubject
27    insertVendor
   
28  **********************************************************/  **********************************************************/
29    
30    
31  /**********************************************************  /**********************************************************
32  Function: insertCoursesub  Function: insertCoursesub
33  Author: Paul Bramscher  Author: Paul Bramscher
34  Last Modified: 06.03.2003  Last Modified: 03.15.2004
35  ***********************************************************  ***********************************************************
36  Purpose:  Purpose:
37  Inserts a course subject.  Inserts a course subject.
38  **********************************************************/  **********************************************************/
39  function insertCoursesub($con, $campus_id, $cip_code, $coursesub, $coursesub_descr) {  function insertCoursesub($campus_id, $cip_code, $coursesub, $coursesub_descr) {
40    
41            msgTableOpen(1, "Adding Course Subject...");
42            printf("<b>Messages:</b><br>\n");
43    
44          // Error flag          // Error flag
45          $err_code = 0;            $err_code = 0;  
# Line 47  function insertCoursesub($con, $campus_i Line 49  function insertCoursesub($con, $campus_i
49          $coursesub_search = textSearchmySQL($coursesub);          $coursesub_search = textSearchmySQL($coursesub);
50    
51          // Check to see if already exists          // Check to see if already exists
52          $exists = recordCount($con, "coursesub", "coursesub", $coursesub_search, "A");          $exists = recordCount("coursesub", "coursesub", $coursesub_search, "A");
53          if ($exists > 0) {          if ($exists > 0) {
54                  $err_code = 1;                  $err_code = 1;
55                  $err_msg = "Failed. '" . $coursesub_display . "' already exists in the course subject table.";                  $err_msg = "Failed. <b>" . $coursesub_display . "</b> already exists in the course subject table.";
56          }          }
57                    
58          // Check for blank entry          // Check for blank entry
# Line 59  function insertCoursesub($con, $campus_i Line 61  function insertCoursesub($con, $campus_i
61                  $err_msg = "Failed.  Cannot enter a blank course subject.";                  $err_msg = "Failed.  Cannot enter a blank course subject.";
62          }          }
63    
         printf("<center><h3>Adding Course Subject...</h3>");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
         printf("<tr><td><br>");  
         printf("<strong>Messages:</strong><br>");  
   
64          // Add only if this coursesub doesn't already exist, and something was supplied          // Add only if this coursesub doesn't already exist, and something was supplied
65          if ($err_code == 0) {          if ($err_code == 0) {
66    
# Line 86  function insertCoursesub($con, $campus_i Line 81  function insertCoursesub($con, $campus_i
81                          . ")";                          . ")";
82                    
83                  // Write the new row to the database                  // Write the new row to the database
84                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added Course Subject <b>%s</b>.", $coursesub_display);
                         sql_err($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
                 }  
                 else {  
                         printf("Added Course Subject <b>%s</b>.<BR>", $coursesub_display);  
                         mysql_query("UNLOCK TABLES", $con);  
                 }  
85          }          }
86          else printf("%s", $err_msg);          else printf("%s", $err_msg);
87            
88          printf("<br><br>\n");          printf("<br><br>\n");
89          printf("</td></tr></table>\n");          msgTableClose();
         printf("</center>\n");  
90  }  }
91    
92    
93  /**********************************************************  /**********************************************************
94  Function: insertFaculty  Function: insertFaculty
95  Author: Paul Bramscher  Author: Paul Bramscher
96  Last Modified: 06.24.2003  Last Modified: 03.15.2004
97  ***********************************************************  ***********************************************************
98  Purpose:  Purpose:
99  Inserts a faculty member.  Inserts a faculty member.  Faculty must have a last name,
100    and unique first/last name pair.
101  **********************************************************/  **********************************************************/
102  function insertFaculty($con, $faculty_email, $faculty_firstname,  function insertFaculty($faculty_email, $faculty_firstname,
103          $faculty_lastname, $faculty_account) {          $faculty_lastname, $faculty_account) {
104    
105          /*          msgTableOpen(1, "Adding Faculty...");
106          Faculty must have both a unique non-blank staff_account, and non-blank last name.          printf("<b>Messages:</b><br>\n");      
         */  
107    
108          // Error flag          // Error flag
109          $err_code = 0;            $err_code = 0;  
110    
111          // Need for display/uniqueness          // Need for display/uniqueness
112          $faculty_name_display = $faculty_firstname . " " . $faculty_lastname;          $faculty_name_display = $faculty_firstname . " " . $faculty_lastname;
113          $exists_id = existsFaculty($con, $faculty_firstname, $faculty_lastname);          $exists_id = existsFaculty($faculty_firstname, $faculty_lastname);
114    
115          if ($exists_id > 0) {          if ($exists_id > 0) {
116                  $err_code = 1;                  $err_code = 1;
117                  $err_msg = "Failed. '" . $faculty_name_display . "' already exists in the Faculty table.";                  $err_msg = "Failed. <b>" . $faculty_name_display . "</b> already exists in the Faculty table.";
118          }          }
119    
120          // Check for blank last name          // Check for blank last name
# Line 136  function insertFaculty($con, $faculty_em Line 123  function insertFaculty($con, $faculty_em
123                  $err_msg = "Failed.  Cannot enter a blank Last Name.";                  $err_msg = "Failed.  Cannot enter a blank Last Name.";
124          }          }
125    
         printf("<center><h3>Adding Faculty...</h3>");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
         printf("<tr><td><br>");  
         printf("<strong>Messages:</strong><br>");  
   
126          // Add only if no errors encountered          // Add only if no errors encountered
127          if ($err_code == 0) {          if ($err_code == 0) {
128    
# Line 163  function insertFaculty($con, $faculty_em Line 143  function insertFaculty($con, $faculty_em
143                          . "', '"                          . "', '"
144                          . $faculty_account                          . $faculty_account
145                          . "')";                          . "')";
146                    
147                  // Write the new row to the database                  // Write the new row to the database
148                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added <b>%s</b> to the faculty table.", $faculty_name_display);
                         sql_err($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
         }  
                 else {  
                         printf("Added <b>%s</b> to the faculty table.<BR>\n", $faculty_name_display);  
                         mysql_query("UNLOCK TABLES", $con);  
                 }  
149          }          }
150                    
151          else printf("%s", $err_msg);          else printf("%s", $err_msg);
152            
153          printf("<br><br>\n");          printf("<br><br>\n");
154          printf("</td></tr></table>\n");          msgTableClose();
         printf("</center>\n");  
155  }  }
156    
157    
158  /**********************************************************  /**********************************************************
159  Function: insertFeature  Function: insertFeature
160  Author: Paul Bramscher  Author: Paul Bramscher
161  Last Modified: 05.21.2003  Last Modified: 03.15.2004
162  ***********************************************************  ***********************************************************
163  Purpose:  Purpose:
164  Inserts a feature.  Inserts a feature.
165  **********************************************************/  **********************************************************/
166  function insertFeature($con, $feature, $image_alt, $image_path) {  function insertFeature($feature, $image_alt, $image_path) {
167    
168            msgTableOpen(1, "Adding Feature...");
169            printf("<b>Messages:</b><br>\n");      
170    
171          // Error flag          // Error flag
172          $err_code = 0;            $err_code = 0;  
# Line 201  function insertFeature($con, $feature, $ Line 176  function insertFeature($con, $feature, $
176          $feature_search = textSearchmySQL($feature);          $feature_search = textSearchmySQL($feature);
177    
178          // Check to see if already exists          // Check to see if already exists
179          $exists = recordCount($con, "feature", "feature", $feature_search, "A");          $exists = recordCount("feature", "feature", $feature_search, "A");
180          if ($exists > 0) {          if ($exists > 0) {
181                  $err_code = 1;                  $err_code = 1;
182                  $err_msg = "Failed. '" . $feature_display . "' already exists in the feature table.";                  $err_msg = "Failed. <b>" . $feature_display . "</b> already exists in the feature table.";
183          }          }
184                    
185          // Check for blank entry          // Check for blank entry
# Line 213  function insertFeature($con, $feature, $ Line 188  function insertFeature($con, $feature, $
188                  $err_msg = "Failed.  Cannot enter a blank feature.";                  $err_msg = "Failed.  Cannot enter a blank feature.";
189          }          }
190    
         printf("<center><h3>Adding Feature...</h3>");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
         printf("<tr><td><br>");  
         printf("<strong>Messages:</strong><br>");  
   
191          // Add only if this feature doesn't already exist, and something was supplied          // Add only if this feature doesn't already exist, and something was supplied
192          if ($err_code == 0) {          if ($err_code == 0) {
193    
# Line 238  function insertFeature($con, $feature, $ Line 206  function insertFeature($con, $feature, $
206                          . "')";                          . "')";
207                    
208                  // Write the new row to the database                  // Write the new row to the database
209                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added Feature <b>%s</b>.", $feature_display);
210                          sql_err($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
         }  
                 else {  
                         printf("Added Feature <b>%s</b>.<BR>", $feature_display);  
                         mysql_query("UNLOCK TABLES", $con);  
                 }  
211          }          }
212          else printf("%s", $err_msg);          else printf("%s", $err_msg);
213            
214          printf("<br><br>\n");          printf("<br><br>\n");
215          printf("</td></tr></table>\n");          msgTableClose();
         printf("</center>\n");  
216  }  }
217    
218    
219  /**********************************************************  /**********************************************************
220  Function: insertInfotype  Function: insertInfotype
221  Author: Paul Bramscher  Author: Paul Bramscher
222  Last Modified: 05.21.2003  Last Modified: 03.15.2004
223  ***********************************************************  ***********************************************************
224  Purpose:  Purpose:
225  Inserts an information type.  Inserts an information type.
226  **********************************************************/  **********************************************************/
227  function insertInfotype($con, $infotype, $masterinfotype_id, $mastersubject_id) {  function insertInfotype($infotype, $masterinfotype_id, $mastersubject_id) {
228    
229            msgTableOpen(1, "Adding Information Type...");
230            printf("<b>Messages:</b><br>\n");
231    
232          // Error flag          // Error flag
233          $err_code = 0;            $err_code = 0;  
# Line 273  function insertInfotype($con, $infotype, Line 237  function insertInfotype($con, $infotype,
237          $infotype_search = textSearchmySQL($infotype);          $infotype_search = textSearchmySQL($infotype);
238                    
239          // Check to see if already exists          // Check to see if already exists
240          $exists = recordCount($con, "infotype", "infotype", $infotype_search, "A");          $exists = recordCount("infotype", "infotype", $infotype_search, "A");
241                    
242          // If exists in the table          // If exists in the table
243          if ($exists > 0) {          if ($exists > 0) {
244                  $err_code = 1;                  $err_code = 1;
245                  $err_msg = "Failed. '" . $infotype_display . "' already exists in the Information Type table.";                  $err_msg = "Failed. <b>" . $infotype_display . "</b> already exists in the Information Type table.";
246          }          }
247                    
248          // Check for blank entry          // Check for blank entry
# Line 287  function insertInfotype($con, $infotype, Line 251  function insertInfotype($con, $infotype,
251                  $err_msg = "Failed.  Must supply some value for the Information Type name.";                  $err_msg = "Failed.  Must supply some value for the Information Type name.";
252          }          }
253    
   
         printf("<center><h3>Adding Information Type...</h3>");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
         printf("<tr><td><br>");  
         printf("<strong>Messages:</strong><br>");  
   
254          // Add only if this infotype doesn't already exist          // Add only if this infotype doesn't already exist
255          if ($err_code == 0) {          if ($err_code == 0) {
256    
# Line 311  function insertInfotype($con, $infotype, Line 267  function insertInfotype($con, $infotype,
267                          . ")";                          . ")";
268                                    
269                  // Write the new row to the database                  // Write the new row to the database
270                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added Information Type <b>%s</b>.", $infotype_display);
271                          sql_err($con);          }
272                          mysql_query ("UNLOCK TABLES", $con);          else printf("%s", $err_msg);
273                          bailout();          
274                  }          printf("<br><br>\n");
275                  else {          msgTableClose();
                         printf("Added Information Type <b>%s</b>.<BR>", $infotype_display);  
                         mysql_query("UNLOCK TABLES", $con);  
                 }  
         }  
   
         else printf("%s<BR><BR>", $err_msg);  
   
         // Close the table  
         printf("<BR>");  
         printf("</td></tr></table>");  
         printf("</center>");  
276  }  }
277    
278    
279  /**********************************************************  /**********************************************************
280  Function: insertLibunit  Function: insertLibunit
281  Author: Paul Bramscher  Author: Paul Bramscher
282  Last Modified: 05.22.2003  Last Modified: 03.15.2004
283  ***********************************************************  ***********************************************************
284  Purpose:  Purpose:
285  Inserts the supplied library unit information into the  Inserts the supplied library unit information into the
286  database, and calls formLibunit back again, if the  database, and calls formLibunit back again, if the
287  insert passed a few checks (unique, no blank values, etc.)  insert passed a few checks (unique, no blank values, etc.)
 **********************************************************/  
 function insertLibunit($con, $head_staff_id, $libunit, $libunit_abbrev) {  
288    
289          /*  Library Units must have both a unique name and unique
290          Library Units must have both a unique name and unique abbreviation  abbreviation e.g. "Digital Library Developement Laboratory"
291          e.g. "Digital Library Developement Laboratory" and "DLDL"  and "DLDL".
292          Additionally, empty values are not allowed.  **********************************************************/
293          */  function insertLibunit($head_staff_id, $libunit, $libunit_abbrev) {
294    
295          // Error flag          // Error flag
296          $err_code = 0;            $err_code = 0;  
# Line 359  function insertLibunit($con, $head_staff Line 302  function insertLibunit($con, $head_staff
302          $libunit_abbrev_search = textSearchmySQL($libunit_abbrev);          $libunit_abbrev_search = textSearchmySQL($libunit_abbrev);
303    
304          // Check to see if libunit already exists          // Check to see if libunit already exists
305          $exists = recordCount($con, "libunit", "libunit", $libunit_search, "A");          $exists = recordCount("libunit", "libunit", $libunit_search, "A");
306          if ($exists > 0) {          if ($exists > 0) {
307                  $err_code = 1;                  $err_code = 1;
308                  $err_msg = "Failed. '" . $libunit_display . "' already exists in the Library Unit table.";                  $err_msg = "Failed. <b>" . $libunit_display . "</b> already exists in the Library Unit table.";
309          }          }
310    
311          // Check to see if libunit abbreviation already exists          // Check to see if libunit abbreviation already exists
312          $exists = recordCount($con, "libunit", "libunit_abbrev", $libunit_abbrev_search, "A");          $exists = recordCount("libunit", "libunit_abbrev", $libunit_abbrev_search, "A");
313          if ($exists > 0) {          if ($exists > 0) {
314                  $err_code = 2;                  $err_code = 2;
315                  $err_msg = "Failed. '" . $libunit_abbrev_display . "' abbreviation already exists in the Library Unit table.";                  $err_msg = "Failed. <b>" . $libunit_abbrev_display . "</b> abbreviation already exists in the Library Unit table.";
316          }          }
317    
318          // Check for blank linunit entry          // Check for blank linunit entry
# Line 399  function insertLibunit($con, $head_staff Line 342  function insertLibunit($con, $head_staff
342                          . ")";                          . ")";
343                                    
344                  // Write the new row to the database                  // Write the new row to the database
345                  mysql_query ("LOCK TABLE libunit WRITE", $con);                  mysql_tryquery ($sql);
346                  if (!mysql_query($sql, $con)){                  $libunit_id = mysql_insert_id();
347                          sql_err($con);                  formLibunit($libunit_id);
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
         }  
                 else {  
                         $libunit_id = mysql_insert_id($con);              
                         mysql_query("UNLOCK TABLES", $con);  
                         formLibunit($con, $libunit_id);  
                 }  
348          }          }
           
349          else {          else {
350                  printf("<center><h3>Adding Library Unit...</h3>");                  msgTableOpen(1, "Adding Library Unit...");
351                    printf("<b>Messages:</b><br>\n");      
                 // Table  
                 printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n");  
                 printf("<tr><td><br>\n");  
                 printf("<strong>Messages:</strong><br>\n");  
352                  printf("%s", $err_msg);                  printf("%s", $err_msg);
353                  printf("<BR><BR>\n");                  printf("<br><br>\n");
354                  printf("</td></tr></table>\n");                  msgTableClose();        
                 printf("</center>\n");  
355          }          }
356  }  }
357    
# Line 430  function insertLibunit($con, $head_staff Line 359  function insertLibunit($con, $head_staff
359  /**********************************************************  /**********************************************************
360  Function: insertLocation  Function: insertLocation
361  Author: Paul Bramscher  Author: Paul Bramscher
362  Last Modified: 06.16.2003  Last Modified: 03.15.2004
363  ***********************************************************  ***********************************************************
364  Purpose:  Purpose:
365  Inserts a library/location.  Inserts a library/location.
366  **********************************************************/  **********************************************************/
367  function insertLocation($con, $address1, $address2, $address3,  function insertLocation($address1, $address2, $address3,
368          $address4, $campus, $hoursURL, $location, $location_descr, $mainURL,          $address4, $campus, $hoursURL, $location, $location_descr, $mainURL,
369          $mapURL, $referenceURL, $telephone) {          $mapURL, $referenceURL, $telephone) {
370    
371            msgTableOpen(1, "Adding Location...");
372            printf("<b>Messages:</b><br>\n");
373    
374          // Need for display purposes          // Need for display purposes
375          $location_display = $location;          $location_display = $location;
376          $location_search = textSearchmySQL($location);          $location_search = textSearchmySQL($location);
# Line 447  function insertLocation($con, $address1, Line 379  function insertLocation($con, $address1,
379          $err_code = 0;            $err_code = 0;  
380    
381          // Check to see if already exists          // Check to see if already exists
382          $exists = recordCount($con, "location", "location", $location_search, "A");          $exists = recordCount("location", "location", $location_search, "A");
383          if ($exists > 0) {          if ($exists > 0) {
384                  $err_code = 1;                  $err_code = 1;
385                  $err_msg = "Failed. '" . $location_display . "' already exists in the location table.";                  $err_msg = "Failed. <b>" . $location_display . "</b> already exists in the location table.";
386          }          }
387                    
388          // Check for blank entry          // Check for blank entry
# Line 459  function insertLocation($con, $address1, Line 391  function insertLocation($con, $address1,
391                  $err_msg = "Failed.  Cannot enter a blank location.";                  $err_msg = "Failed.  Cannot enter a blank location.";
392          }          }
393    
         printf("<center><h3>Adding Location...</h3>\n");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n");  
         printf("<tr><td><br>\n");  
         printf("<strong>Messages:</strong><br>\n");  
   
394          // Add only if this location doesn't already exist, and something was supplied          // Add only if this location doesn't already exist, and something was supplied
395          if ($err_code == 0) {          if ($err_code == 0) {
396    
# Line 513  function insertLocation($con, $address1, Line 438  function insertLocation($con, $address1,
438                          . "')";                          . "')";
439    
440                  // Write the new row to the database                  // Write the new row to the database
441                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added <b>%s</b> location.", $location_display);
442                          sql_err($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
                 }  
                 else {  
   
                         printf("Added <b>%s</b> location.", $location_display);  
                         mysql_query("UNLOCK TABLES", $con);  
                 }  
443          }          }
           
444          else printf("%s", $err_msg);          else printf("%s", $err_msg);
445            
446          printf("<br><br>\n");          printf("<br><br>\n");
447          printf("</td></tr></table>\n");          msgTableClose();
         printf("</center>\n");  
448    
449  }  }
450    
# Line 536  function insertLocation($con, $address1, Line 452  function insertLocation($con, $address1,
452  /**********************************************************  /**********************************************************
453  Function: insertResource  Function: insertResource
454  Author: Paul Bramscher  Author: Paul Bramscher
455  Last Modified: 04.21.2003  Last Modified: 03.15.2004
456  ***********************************************************  ***********************************************************
457  Purpose:  Purpose:
458  Inserts a resource.  Inserts a resource.
459  **********************************************************/  **********************************************************/
460  function insertResource($con, $annotation, $author, $call_no, $cat_num,  function insertResource($annotation, $author, $call_no, $cat_num,
461          $coverage_detail, $edition, $infotype_id, $mastersubject_id, $other_title,          $coverage_detail, $edition, $guide_url, $infotype_id, $mastersubject_id,
462          $pub_date, $publisher, $sess_staff_account, $sources_indexed, $title, $url) {          $other_title, $pub_date, $publisher, $resource_message, $resource_status,
463            $sess_staff_account, $sources_indexed, $title, $url, $vendor_id) {
464    
465          // Error flag          // Error flag
466          $err_code = 0;            $err_code = 0;  
467    
468          // Check to see if already exists          // Check to see if already exists
469          $exists = recordCount($con, "resource", "title", $title, "A");          $exists = recordCount("resource", "title", $title, "A");
470                    
471          // If exists in the table          // If exists in the table
472          if ($exists > 0) {          if ($exists > 0) {
473                  $err_code = 1;                  $err_code = 1;
474                  $err_msg = "Failed. '" . $title . "' already exists in the Resource table.";                  $err_msg = "Failed. <b>" . $title . "</b> already exists in the Resource table.";
475          }          }
476                    
477          // Check for blank entry          // Check for blank entry
# Line 579  function insertResource($con, $annotatio Line 496  function insertResource($con, $annotatio
496                  if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed);                  if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed);
497                  if (strlen($title) > 0) $title = textInmySQL($title);                  if (strlen($title) > 0) $title = textInmySQL($title);
498                  if (strlen($url) > 0) $url = textInmySQL($url);                  if (strlen($url) > 0) $url = textInmySQL($url);
499                    if (strlen($guide_url) > 0) $guide_url = textInmySQL($guide_url);              
500                    if (strlen($resource_message) > 0) $resource_message = textInmySQL($resource_message);
501                    if ($resource_status < 1) {
502                            $resource_status = "";
503                            $resource_message = "";
504                    }              
505    
506                  // Build the SQL                  // Build the SQL
507                  $sql = "INSERT INTO resource (annotation, author, call_no, cat_num,                  $sql = "INSERT INTO resource (annotation, author, call_no, cat_num,
508                          coverage_detail, date_created, date_modified, edition,                          coverage_detail, date_created, date_modified, edition, guide_url,
509                          infotype_id, other_title, pub_date, publisher, sources_indexed,                          infotype_id, other_title, pub_date, publisher, resource_message,
510                          title, url, account_created) VALUES ('"                          resource_status, sources_indexed, title, url, vendor_id,
511                            account_created) VALUES ('"
512                          . $annotation                          . $annotation
513                          . "', '"                          . "', '"
514                          . $author                          . $author
# Line 596  function insertResource($con, $annotatio Line 520  function insertResource($con, $annotatio
520                          . $coverage_detail                          . $coverage_detail
521                          . "', now(), now(), '"                          . "', now(), now(), '"
522                          . $edition                          . $edition
523                            . "', '"
524                            . $guide_url
525                          . "', "                          . "', "
526                          . $infotype_id                          . $infotype_id
527                          . ", '"                          . ", '"
# Line 605  function insertResource($con, $annotatio Line 531  function insertResource($con, $annotatio
531                          . "', '"                          . "', '"
532                          . $publisher                          . $publisher
533                          . "', '"                          . "', '"
534                            . $resource_message
535                            . "', '"
536                            . $resource_status
537                            . "', '"
538                          . $sources_indexed                          . $sources_indexed
539                          . "', '"                          . "', '"
540                          . $title                          . $title
541                          . "', '"                          . "', '"
542                          . $url                          . $url
543                          . "', '"                          . "', '"
544                            . $vendor_id
545                            . "', '"
546                          . $sess_staff_account                          . $sess_staff_account
547                          . "')";                          . "')";
548    
                 // Debugging  
                 // printf("sql was: %s<BR>", $sql);  
   
549                  // Write the new record to the database                  // Write the new record to the database
550                  mysql_query ("LOCK TABLE resource WRITE", $con);                  mysql_tryquery ($sql);
551                  if (!mysql_query($sql, $con)){                  $resource_id = mysql_insert_id();
552                          sql_err($con);  
553                          mysql_query ("UNLOCK TABLES", $con);                  // Now set up this resource with its first mastersubject
554                          bailout();                  // Note that id#1 = N/A and id#2 = (All) are not used here.
555                  }                  if ($mastersubject_id > 2) {      
556                  else {                          $sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES ("
557                          $resource_id = mysql_insert_id($con);                                  . $resource_id
558                          mysql_query("UNLOCK TABLES", $con);                                  . ", "
559                                    . $mastersubject_id
560                          // Now set up this resource with its first mastersubject                                  . ")";
561                          // Note that id#1 = N/A and id#2 = (All), and are not used here.                          // Write the new res_mastersubject to the database
562                          if ($mastersubject_id > 2) {                                mysql_tryquery ($sql);
                                 $sql = "INSERT INTO res_mastersubject (resource_id, mastersubject_id) VALUES ("  
                                         . $resource_id  
                                         . ", "  
                                         . $mastersubject_id  
                                         . ")";  
   
                                 // Write the new res_mastersubject to the database  
                                 mysql_query ("LOCK TABLE res_mastersubject WRITE", $con);  
                                 if (!mysql_query($sql, $con)){  
                                         sql_err($con);  
                                         mysql_query ("UNLOCK TABLES", $con);  
                                         bailout();  
                                 }  
                                 else {  
                                         mysql_query("UNLOCK TABLES", $con);  
                                 }  
                         }  
563                  }                  }
564    
565                  // Call the formResource page back, in case user wants to edit further                  // Call the formResource page back, in case user wants to edit further
566                  formResource($con, $resource_id, 0, 0, '');                  formResource($resource_id, 0, 0, '');
567    
568          } // end insert new resource          } // end insert new resource
569                    
570          else {          else {
571                  printf("<center><h3>Adding Resource...</h3>");                  msgTableOpen(1, "Adding Resource...");
572                    printf("<b>Messages:</b><br>\n");      
                 // Table  
                 printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n");  
                 printf("<tr><td><br>\n");  
                 printf("<strong>Messages:</strong><br>\n");  
573                  printf("%s", $err_msg);                  printf("%s", $err_msg);
574                  printf("<BR><BR>\n");                  printf("<br><br>\n");
575                  printf("</td></tr></table>\n");                  msgTableClose();
                 printf("</center>\n");  
         } // end error messages  
   
 } // end function  
   
   
 /**********************************************************  
 Function: insertSingleField  
 Author: Paul Bramscher  
 Last Modified: 05.21.2003  
 ***********************************************************  
 Purpose:  
 Inserts any single field value into any table.  
 **********************************************************/  
 function insertSingleField($con, $display, $field, $newValue, $table){  
   
         // Error flag  
         $err_code = 0;    
   
         // Need for display/uniqueness purposes  
         $newValue_search = textSearchmySQL($newValue);  
         $newValue_display = $newValue;    
   
         // Check to see if already exists  
         $exists = recordCount($con, $table, $field, $newValue_search, "A");  
         if ($exists > 0) {  
                 $err_code = 1;  
                 $err_msg = "Failed. <b>"  
                         . $newValue_display  
                         . "</b> already exists in the "  
                         . $display  
                         . " table.";  
         }  
           
         // Check for blank entry  
         if ($newValue == "") {  
                 $err_code = 2;  
                 $err_msg = "Failed.  Cannot enter a blank <b>"  
                         . $display  
                         . "</b> value.";  
         }  
   
         // Draw page heading  
         printf("<center><h3>Adding New %s</h3>", $display);  
   
         printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">");  
         printf("<tr><td><b>Messages:</b><br>");  
   
         // Add only if this item doesn't already exist, and a value was supplied  
         if ($err_code == 0){  
   
                 // Clean up strings  
                 $newValue  = textInmySQL($newValue);  
   
                 // Build the SQL  
                 $sql = "INSERT INTO "  
                         . $table  
                         ." ("  
                         . $field  
                         . ") VALUES ('"  
                         . $newValue  
                         . "')";  
   
                 // Debugging  
                 // printf("sql was: %s<br>", $sql);  
   
                 if (!mysql_query ($sql, $con)){  
                         sql_err($sql);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
                 }  
                 else {  
                         $new_id = mysql_insert_id($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         printf("%s <b>%s</b> successfully added.\n", $display, $newValue_display);  
                 }  
576          }          }
577    
578          else printf ("%s\n", $err_msg);  } // end function
         printf("<br><br></td></tr></table>");  
         printf("</center>");  
 }  
579    
580    
581  /**********************************************************  /**********************************************************
582  Function: insertService  Function: insertService
583  Author: Paul Bramscher  Author: Paul Bramscher
584  Last Modified: 05.21.2003  Last Modified: 03.15.2004
585  ***********************************************************  ***********************************************************
586  Purpose:  Purpose:
587  Inserts a service.  Inserts a service.
588  **********************************************************/  **********************************************************/
589  function insertService($con, $address1, $address2, $address3, $address4,  function insertService($address1, $address2, $address3, $address4,
590          $email, $fax, $nonaff, $service, $serviceDescr, $serviceURL, $telephone) {          $email, $fax, $nonaff, $service, $serviceDescr, $serviceURL, $telephone) {
591    
592          // Error flag          // Error flag
# Line 768  function insertService($con, $address1, Line 597  function insertService($con, $address1,
597          $service_search = textSearchmySQL($service);          $service_search = textSearchmySQL($service);
598    
599          // Check to see if already exists          // Check to see if already exists
600          $exists = recordCount($con, "service", "service", $service_search, "A");          $exists = recordCount("service", "service", $service_search, "A");
601          if ($exists > 0) {          if ($exists > 0) {
602                  $err_code = 1;                  $err_code = 1;
603                  $err_msg = "Failed. '" . $service_display . "' already exists in the service table.";                  $err_msg = "Failed. <b>" . $service_display . "</b> already exists in the service table.";
604          }          }
605                    
606          // Check for blank entry          // Check for blank entry
# Line 823  function insertService($con, $address1, Line 652  function insertService($con, $address1,
652                          . "')";                          . "')";
653                                    
654                  // Write the new row to the database                  // Write the new row to the database
655                  mysql_query ("LOCK TABLE service WRITE", $con);                  mysql_tryquery ($sql);
656                  if (!mysql_query($sql, $con)){                  $service_id = mysql_insert_id();
657                          sql_err($con);                  formService($service_id);
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
                 }  
                 else {  
                         $service_id = mysql_insert_id($con);  
                         mysql_query("UNLOCK TABLES", $con);  
                         formService($con, $service_id);                  
                 }  
658          }          }
659    
660          else {          else {
661                  // Draw page heading                  msgTableOpen(1, "Adding Service...");
662                  printf("<center><h3>Adding New Service...</h3>");                  printf("<b>Messages:</b><br>\n");      
663                    printf("%s", $err_msg);
664                    printf("<br><br>\n");
665                    msgTableClose();
666            }
667    
668    }
669    
670    
671    /**********************************************************
672    Function: insertSingleField
673    Author: Paul Bramscher
674    Last Modified: 03.15.2004
675    ***********************************************************
676    Purpose:
677    Inserts any single field value into any table.
678    **********************************************************/
679    function insertSingleField($display, $field, $newValue,
680            $table) {
681    
682                  printf("<table width =\"50%%\" border = \"3\" class=\"backLight\">");          msgTableOpen(1, "Adding " . $display . "...");
683                  printf("<tr><td><b>Messages:</b><br>");          printf("<b>Messages:</b><br>\n");      
684    
685            // Error flag
686            $err_code = 0;  
687    
688            // Need for display/uniqueness purposes
689            $newValue_search = textSearchmySQL($newValue);
690            $newValue_display = $newValue;  
691    
692            // Check to see if already exists
693            $exists = recordCount($table, $field, $newValue_search, "A");
694            if ($exists > 0) {
695                    $err_code = 1;
696                    $err_msg = "Failed. <b>"
697                            . $newValue_display
698                            . "</b> already exists in the "
699                            . $display
700                            . " table.";
701            }
702                    
703                  printf ("%s\n", $err_msg);          // Check for blank entry
704                  printf("<br><br></td></tr></table>");          if ($newValue == "") {
705                  printf("</center>");                  $err_code = 2;
706                    $err_msg = "Failed.  Cannot enter a blank <b>"
707                            . $display
708                            . "</b> value.";
709          }          }
710    
711            // Add only if this item doesn't already exist, and a value was supplied
712            if ($err_code == 0){
713    
714                    // Clean up strings
715                    $newValue  = textInmySQL($newValue);
716    
717                    // Build the SQL
718                    $sql = "INSERT INTO "
719                            . $table
720                            ." ("
721                            . $field
722                            . ") VALUES ('"
723                            . $newValue
724                            . "')";
725    
726                    mysql_tryquery ($sql);
727                    $new_id = mysql_insert_id();
728                    printf("%s <b>%s</b> successfully added.", $display, $newValue_display);
729            }
730            else printf ("%s", $err_msg);
731            
732            printf("<br><br>\n");
733            msgTableClose();
734  }  }
735    
736    
737  /**********************************************************  /**********************************************************
738  Function: insertStaff  Function: insertStaff
739  Author: Paul Bramscher  Author: Paul Bramscher
740  Last Modified: 06.23.2003  Last Modified: 03.15.2004
741  ***********************************************************  ***********************************************************
742  Purpose:  Purpose:
743  Inserts the supplied staffperson information, and calls  Inserts the supplied staffperson information, and calls
744  formStaff back again if the insert was valid.  formStaff back again if the insert was valid.   Staff must
745    have, at a minimum, a last name, first name, and unique
746    staff account name.  Uniqueness is enforced only on
747    staff_account.
748  **********************************************************/  **********************************************************/
749  function insertStaff($con, $access_id, $first_name,  function insertStaff($access_id, $first_name,
750          $last_name, $sess_access_level, $staff_account, $staff_email, $stafftitle_id) {          $last_name, $sess_access_level, $staff_account,
751            $staff_email, $stafftitle_id) {
         /*  
         Staff must have, at a minimum, a last name, first name, and unique staff account name.  
         Uniqueness is enforced only on staff_account.  
         */  
752    
753          // Error flag          // Error flag
754          $err_code = 0;            $err_code = 0;  
# Line 875  function insertStaff($con, $access_id, $ Line 758  function insertStaff($con, $access_id, $
758          $staff_account_search = textSearchmySQL($staff_account);          $staff_account_search = textSearchmySQL($staff_account);
759    
760          // Check to see if the account name already exists          // Check to see if the account name already exists
761          $exists = recordCount($con, "staff", "staff_account", $staff_account_search, "A");          $exists = recordCount("staff", "staff_account", $staff_account_search, "A");
762          if ($exists > 0) {          if ($exists > 0) {
763                  $err_code = 1;                  $err_code = 1;
764                  $err_msg = "Failed. '" . $staff_account_display . "' already exists in the Staff table.";                  $err_msg = "Failed. <b>" . $staff_account_display . "</b> already exists in the Staff table.";
765          }          }
766    
767          // Check for blank first name or last name          // Check for blank first name or last name
# Line 894  function insertStaff($con, $access_id, $ Line 777  function insertStaff($con, $access_id, $
777          }          }
778    
779          // Check for access level higher than current access          // Check for access level higher than current access
780          $this_access_level = lookupfield($con, "access", "access_id", $access_id, "access_level");          $this_access_level = lookupfield("access", "access_id", $access_id, "access_level");
781          if ($this_access_level > $sess_access_level) {          if ($this_access_level > $sess_access_level) {
782                  $err_code = 4;                  $err_code = 4;
783                  $err_msg = "Failed.  You may not create staff with higher privileges than your own.";                  $err_msg = "Failed.  You may not create staff with higher privileges than your own.";
# Line 924  function insertStaff($con, $access_id, $ Line 807  function insertStaff($con, $access_id, $
807                          . "', '"                          . "', '"
808                          . $staff_email                          . $staff_email
809                          . "')";                          . "')";
   
                 // Debugging  
                 // printf("sql was: %s<br><br>\n", $sql);  
810                                    
811                  // Write the new row to the database                  // Write the new row to the database
812                  mysql_query ("LOCK TABLE staff WRITE", $con);                  mysql_tryquery ($sql);
813                  if (!mysql_query($sql, $con)){                  $staff_id = mysql_insert_id();
814                          sql_err($con);                  
815                          mysql_query ("UNLOCK TABLES", $con);                  // Call staff form back
816                          bailout();                  formStaff($staff_id);
         }  
                 else {  
   
                         // Success, call formStaff back.  
                         $staff_id = mysql_insert_id($con);  
                         mysql_query("UNLOCK TABLES", $con);  
                         formStaff($con, $staff_id);  
                 }  
817          }          }
818          else {          else {
819                  // Failure message box                  msgTableOpen(1, "Adding Staff...");
820                  printf("<center><h3>Adding Staff...</h3>\n");                  printf("<b>Messages:</b><br>\n");      
                 printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">\n");  
                 printf("<tr><td><br>\n");  
                 printf("<strong>Messages:</strong><br>\n");  
821                  printf("%s", $err_msg);                  printf("%s", $err_msg);
822                  printf("<br><br>\n");                  printf("<br><br>\n");
823                  printf("</td></tr></table>\n");                  msgTableClose();
                 printf("</center>\n");  
824          }          }
825  }  }
826    
# Line 960  function insertStaff($con, $access_id, $ Line 828  function insertStaff($con, $access_id, $
828  /**********************************************************  /**********************************************************
829  Function: insertStyle  Function: insertStyle
830  Author: Paul Bramscher  Author: Paul Bramscher
831  Last Modified: 05.22.2003  Last Modified: 03.15.2004
832  ***********************************************************  ***********************************************************
833  Purpose:  Purpose:
834  Inserts a style type.  Note that css_file, footer_file, and  Inserts a style type.  Note that css_file, footer_file, and
# Line 969  No error checking is done here to ensure Line 837  No error checking is done here to ensure
837  and permissions settings.  This must be accomplished by  and permissions settings.  This must be accomplished by
838  someone with proper OS access.  someone with proper OS access.
839  **********************************************************/  **********************************************************/
840  function insertStyle($con, $css_file, $footer_file, $header_file, $style_title) {  function insertStyle($css_file, $footer_file, $header_file,
841            $style_title) {
842    
843            msgTableOpen(1, "Adding Style...");
844            printf("<b>Messages:</b><br>\n");
845    
846          // Error flag          // Error flag
847          $err_code = 0;            $err_code = 0;  
# Line 979  function insertStyle($con, $css_file, $f Line 851  function insertStyle($con, $css_file, $f
851          $style_title_search = textSearchmySQL($style_title);          $style_title_search = textSearchmySQL($style_title);
852    
853          // Check to see if already exists          // Check to see if already exists
854          $exists = recordCount($con, "style", "style_title", $style_title_search, "A");          $exists = recordCount("style", "style_title", $style_title_search, "A");
855          if ($exists > 0) {          if ($exists > 0) {
856                  $err_code = 1;                  $err_code = 1;
857                  $err_msg = "Failed. '" . $style_title_display . "' already exists in the style table.";                  $err_msg = "Failed. <b>" . $style_title_display . "</b> already exists in the style table.";
858          }          }
859                    
860          // Check for blank entry          // Check for blank entry
# Line 991  function insertStyle($con, $css_file, $f Line 863  function insertStyle($con, $css_file, $f
863                  $err_msg = "Failed.  Cannot enter a blank style.";                  $err_msg = "Failed.  Cannot enter a blank style.";
864          }          }
865    
         printf("<center><h3>Adding Style...</h3>");  
   
         // Table  
         printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
         printf("<tr><td><br>");  
         printf("<strong>Messages:</strong><br>");  
   
866          // Add only if this style doesn't already exist, and something was supplied          // Add only if this style doesn't already exist, and something was supplied
867          if ($err_code == 0) {          if ($err_code == 0) {
868    
# Line 1019  function insertStyle($con, $css_file, $f Line 884  function insertStyle($con, $css_file, $f
884                          . "')";                          . "')";
885                                    
886                  // Write the new row to the database                  // Write the new row to the database
887                  if (!mysql_query($sql, $con)){                  if (mysql_tryquery($sql)) printf("Added <b>%s</b> style.", $style_title_display);
                         sql_err($con);  
                         mysql_query ("UNLOCK TABLES", $con);  
                         bailout();  
                 }  
                 else {  
                         mysql_query("UNLOCK TABLES", $con);                              
                         printf("Added <b>%s</b> style.<br><br>\n", $style_title_display);  
                 }  
888          }          }
889          else printf("%s", $err_msg);          else printf("%s", $err_msg);
890            
891          printf("<br><br>\n");          printf("<br><br>\n");
892          printf("</td></tr></table>\n");          msgTableClose();
         printf("</center>\n");  
893  }  }
894    
895    
896  /**********************************************************  /**********************************************************
897  Function: insertSubject  Function: insertSubject
898  Author: Paul Bramscher  Author: Paul Bramscher
899  Last Modified: 09.23.2003  Last Modified: 03.15.2004
900  ***********************************************************  ***********************************************************
901  Purpose:  Purpose:
902  Inserts a subject.  If successful, calls formSubject  Inserts a subject.  If successful, calls formSubject
903  back again.  back again.
904  **********************************************************/  **********************************************************/
905  function insertSubject($con, $sess_staff_account, $sess_staff_id, $subject, $subject_descr, $sublocation_id) {  function insertSubject($sess_staff_account, $sess_staff_id,
906            $subject, $subject_descr, $sublocation_id) {
907    
908          // Error flag          // Error flag
909          $err_code = 0;            $err_code = 0;  
# Line 1055  function insertSubject($con, $sess_staff Line 913  function insertSubject($con, $sess_staff
913          $subject_search = textSearchmySQL($subject);          $subject_search = textSearchmySQL($subject);
914    
915          // Check to see if already exists          // Check to see if already exists
916          $exists = recordCount($con, "subject", "subject", $subject_search, "A");          $exists = recordCount("subject", "subject", $subject_search, "A");
917          if ($exists > 0) {          if ($exists > 0) {
918                  $err_code = 1;                  $err_code = 1;
919                  $err_msg = "Failed. '" . $subject_display . "' already exists in the subject table.";                  $err_msg = "Failed. <b>" . $subject_display . "</b> already exists in the subject table.";
920          }          }
921                    
922          // Check for blank entry          // Check for blank entry
# Line 1084  function insertSubject($con, $sess_staff Line 942  function insertSubject($con, $sess_staff
942                          . ", now(), '"                          . ", now(), '"
943                          . $sess_staff_account                          . $sess_staff_account
944                          . "')";                          . "')";
945                                    mysql_tryquery ($sql);
946                  // Write the new row to the database                  $subject_id = mysql_insert_id();
947                  mysql_query ("LOCK TABLE subject WRITE", $con);  
948                  if (!mysql_query($sql, $con)){                  // Insert this staff person as an assigned staff member to this subject
949                          sql_err($con);                  $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("
950                          mysql_query ("UNLOCK TABLES", $con);                          . $subject_id
951                          bailout();                          . ", "
952                  }                          . $sess_staff_id
953                  else {                          . ")";
954                          $subject_id = mysql_insert_id($con);                                      mysql_tryquery($sql);                          
955                          mysql_query("UNLOCK TABLES", $con);                  formSubject($subject_id);
   
                         // Insert this staff person as an assigned staff member to this subject  
                         $sql = "INSERT INTO sub_staff (subject_id, staff_id) VALUES ("  
                                 . $subject_id  
                                 . ", "  
                                 . $sess_staff_id  
                                 . ")";  
                                   
                         if (!mysql_query($sql, $con)){  
                                 sql_err($con);  
                                 mysql_query ("UNLOCK TABLES", $con);  
                                 bailout();  
                         }  
                         else {            
                                 mysql_query("UNLOCK TABLES", $con);  
                         }  
                           
                         formSubject($con, $subject_id);  
                 } // good write of subject  
956          }          }
957    
958          else {          else {
959                            msgTableOpen(1, "Adding Subject...");
960                  printf("<center><h3>Adding subject...</h3>");                  printf("<b>Messages:</b><br>\n");      
961                    printf("%s", $err_msg);
962                    printf("<br><br>\n");
963                    msgTableClose();
964            }
965    
966    }
967    
                 // Table  
                 printf("<table width = \"60%%\" border = \"3\" cellpadding =\"4\" class=\"backLight\">");  
                 printf("<tr><td><br>");  
                 printf("<strong>Messages:</strong><br>");  
968    
969                  printf("%s<BR><BR>", $err_msg);  /**********************************************************
970                  printf("</td></tr></table>");  Function: insertVendor
971                  printf("</center>");  Author: Paul Bramscher
972    Last Modified: 03.15.2004
973    ***********************************************************
974    Purpose:
975    Inserts a vendor.
976    **********************************************************/
977    function insertVendor($vendor, $vendor_descr,
978            $vendor_message, $vendor_status) {
979    
980            msgTableOpen(1, "Adding Vendor...");
981            printf("<b>Messages:</b><br>\n");
982    
983            // Error flag
984            $err_code = 0;  
985    
986            // Need for display/uniqueness
987            $vendor_display = $vendor;
988            $vendor_search = textSearchmySQL($vendor);
989    
990            // Check to see if already exists
991            $exists = recordCount("vendor", "vendor", $vendor_search, "A");
992            if ($exists > 0) {
993                    $err_code = 1;
994                    $err_msg = "Failed. <b>" . $vendor_display . "</b> already exists in the vendor table.";
995            }
996            
997            // Check for blank entry
998            if ($vendor == "") {
999                    $err_code = 2;
1000                    $err_msg = "Failed.  Cannot enter a blank vendor.";
1001          }          }
1002    
1003            // Add only if this vendor doesn't already exist, and something was supplied
1004            if ($err_code == 0) {
1005            
1006                    // Clean up strings
1007                    if (strlen($vendor) > 0) $vendor = textInmySQL($vendor);
1008                    if (strlen($vendor_descr) > 0) $vendor_descr = textInmySQL($vendor_descr);
1009                    if (strlen($vendor_message) >0) $vendor_message = textInmySQL($vendor_message);
1010                    if ($vendor_status < 1) {
1011                            $vendor_status = "";
1012                            $vendor_message = "";
1013                    }
1014                    
1015                    // Set up SQL
1016                    $sql = "INSERT INTO vendor (vendor, vendor_descr, vendor_message, vendor_status) VALUES ('"
1017                            . $vendor
1018                            . "', '"
1019                            . $vendor_descr
1020                            . "', '"
1021                            . $vendor_message
1022                            . "', '"
1023                            . $vendor_status
1024                            . "')";
1025                    if (mysql_tryquery($sql)) printf("Added Vendor <b>%s</b>.", $vendor_display);
1026    
1027  } // function          }
1028  ?>          else printf("%s", $err_msg);
1029            printf("<br><br>\n");
1030            msgTableClose();
1031    }
1032    ?>

Legend:
Removed from v.66  
changed lines
  Added in v.67

  ViewVC Help
Powered by ViewVC 1.1.26