anupam_28 Posted March 5, 2007 Share Posted March 5, 2007 I am facing a problem in running a script. Due to server crash all data was lost and unfortunately major portion of programming work was destroyed. somehow we are trying to retrieve the scripts. script below is writtein in PHP 4.0.x and therefore when i try to run it in 5.2.x some problems are there. login problem was already resolved here in this form only thanx for that. now it is next problem in that series. whenever i try to run this script and there are many like this same problem "Object could not found" is retruned in browser. I am not able to find out what exactly is wrong with saving (red below)or save and add portion(blue) of this script is ti due to session variables. plz guide me. <?php include ('./header.php'); echo "<div class='matter'>\n"; $last_record; if (isset($save_ccit)) { $last_record = save_ccit(); foreach ($HTTP_POST_VARS as $var=>$val) { $HTTP_POST_VARS[$var] = ""; } show_ccit_form(); } else if (isset($save_and_add)) { $last_record = save_ccit(); show_ccit_details($last_record); show_cit_form($last_record); } else if (isset($save_cit)) { $last_record = $HTTP_POST_VARS["lastrecord"]; show_ccit_details($last_record); save_cit($last_record); //reset all fields except address, location and place $HTTP_POST_VARS["citpost"] = ""; $HTTP_POST_VARS["citpostcity"] = ""; $HTTP_POST_VARS["citsalutation"] = ""; $HTTP_POST_VARS["citname"] = ""; $HTTP_POST_VARS["citphone1"] = ""; $HTTP_POST_VARS["citphone2"] = ""; $HTTP_POST_VARS["citemail"] = ""; $HTTP_POST_VARS["citfax"] = ""; show_cit_form($last_record); } else { show_ccit_form(); } ?> <?php function show_ccit_details($last_record) { $db = new SQLDB(); $stmt = "SELECT ccit_no, post, a.city as post_city, "; $stmt .= "name, salutation, "; $stmt .= "b.city as city, "; $stmt .= "locations.location as location "; $stmt .= "FROM ccits, cities as a, cities as b, locations "; $stmt .= "WHERE ccits.city_id = b.id "; $stmt .= "AND ccits.post_city = a.id "; $stmt .= "AND ccits.location_id = locations.id "; $stmt .= "AND ccits.id = " . $last_record; //echo $stmt; ?> <?php $db->selectQuery($stmt); if ($row = mysql_fetch_array($db->result)) { ?> <U><b>General Information - CCIT<b></U> <TABLE BORDER=1> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=33*><COL WIDTH=125*> <THEAD></THEAD> <TBODY> <TR VALIGN=TOP> <TD>Post</TD> <TD><? echo $row["post"] . ", " .$row["post_city"] ?></TD> <TD>Name</TD> <TD><? echo $row["salutation"] . " " . $row["name"] ?></TD> </TR> <TR VALIGN=TOP> <TD>City:</TD> <TD><? echo $row["city"] ?></TD> <TD>Audit Party Location:</TD> <TD><? echo $row["location"] ?></TD> </TR> </TBODY> </TABLE> <?php } //end if ?> <hr> <table> <?php //extract CIT Details from cits for CITs already entered $stmt = "SELECT post, cities.city as city "; $stmt .= "FROM cits, cities "; $stmt .= "WHERE cits.post_city = cities.id "; $stmt .= "AND cits.ccit_id = " . $last_record; $db->selectQuery($stmt); while ($row = mysql_fetch_array($db->result)) { ?> <tr><td><? echo $row["post"] ?></td> <td><? echo $row["city"] ?></td></tr> <?php }//end while ?> </table> <?php }//end function show_ccit_details ?> <?php //function show_ccit_form() //displays a blank form for entering ccit details function show_ccit_form() { global $HTTP_POST_VARS; global $PHP_SELF; $salutations = new HTMLList("salutations", "ccitsalutation"); $ccit_locations = new HTMLList("locations", "ccitlocation"); $ccit_cities = new HTMLList("cities", "ccitcity"); $ccit_post_cities = new HTMLList("cities", "ccitpostcity"); ?> <form name=ccitform action=<? echo $PHP_SELF ?> method=post> <U><b>General Information - CCIT<b></U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=33*><COL WIDTH=125*> <THEAD></THEAD> <TBODY> <TR VALIGN=TOP> <TD WIDTH=10%>Post</TD> <TD WIDTH=40%><input type=text name=ccitpost maxlength=20 value='<?php echo $HTTP_POST_VARS["ccitpost"] ?>'> <?php echo $ccit_post_cities->show_list("id", "city", "city", $HTTP_POST_VARS["ccitpostcity"])?></TD> <TD WIDTH=13%>CCIT No</TD> <TD WIDTH=37%><input type=text name=ccitno maxlength=5 size=6 value='<?php echo $HTTP_POST_VARS["ccitno"]?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Name</TD> <TD COLSPAN=3 WIDTH=90%><?php echo $salutations->show_list("salutation", "salutation", "", $HTTP_POST_VARS["ccitsalutation"])?> <input type=text name=ccitname maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["ccitname"]?>'></TD> </TR> </TBODY> </TABLE> <br> <U><b>Address Details<b></U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=22*><COL WIDTH=136*> <TR VALIGN=TOP> <TD WIDTH=10%>Location</TD> <TD COLSPAN=3 WIDTH=90%><?php echo $ccit_locations->show_list("id", "location", "location", $HTTP_POST_VARS["ccitlocation"])?></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Address</TD> <TD COLSPAN=3 WIDTH=90%><input type=text name=ccitaddress1 maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["ccitaddress1"]?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%><BR></TD> <TD COLSPAN=3 WIDTH=90%><input type=text name=ccitaddress2 maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["ccitaddress2"]?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>City</TD> <TD WIDTH=28%><?php echo $ccit_cities->show_list("id", "city", "city", $HTTP_POST_VARS["ccitcity"])?></TD> <TD WIDTH=9%>PIN</TD> <TD WIDTH=53%><input type=text name=ccitpin maxlength=6 size=7 value='<?php echo $HTTP_POST_VARS["ccitpin"]?>'></TD> </TR> </TABLE> <br><U>Contact Details</U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=56*><COL WIDTH=102*> <TR VALIGN=TOP> <TD WIDTH=10%>Phones</TD> <TD COLSPAN=3 WIDTH=90%>1)<input type=text name=ccitphone1 maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["ccitphone1"]?>'> 2)<input type=text name=ccitphone2 maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["ccitphone2"]?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Email</TD> <TD WIDTH=28%><input type=text name=ccitemail maxlength=100 size=50 value='<?php echo $HTTP_POST_VARS["ccitemail"]?>'></TD> <TD WIDTH=22%>FAX</TD> <TD WIDTH=40%><input type=text name=ccitfax maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["ccitfax"]?>'> </TD> </TR> </TABLE> <TABLE WIDTH=100%> <COL WIDTH=85*><COL WIDTH=85*><COL WIDTH=85*> <TR VALIGN=TOP> <TD WIDTH=33% align=center><input class=button type=submit name=save_ccit value='Save'> </TD> <TD WIDTH=33% align=center><input class=button type=submit name=save_and_add value='Save and Add CITs'> </TD> <TD WIDTH=33% align=center><input class=button type=reset name=cancel value='Cancel'> </TD> </TR> </TABLE> </form> <?php } //end function show_ccit_form() ?> <?php function save_ccit() { global $HTTP_POST_VARS; if (empty($HTTP_POST_VARS["ccitpost"]) || empty($HTTP_POST_VARS["ccitpostcity"])) $err[] = "CCIT Post must be filled in."; if (empty($HTTP_POST_VARS["ccitname"])) $err[] = "CCIT's name must be filled in."; if (empty($HTTP_POST_VARS["ccitlocation"])) $err[] = "Audit Party's location must be filled in."; if (empty($HTTP_POST_VARS["ccitaddress1"]) && empty($HTTP_POST_VARS["ccitaddress2"])) $err[] = "CCIT's address must be filled in."; if (empty($HTTP_POST_VARS["ccitcity"])) $err[] = "CCIT's location must be filled in."; //$post = $HTTP_POST_VARS["ccitpost"] . ", " . $HTTP_POST_VARS["ccitpostcity"]; if (!(empty($err))) { echo "<ul>\n"; for ($i = 0; $i < count($err); $i++) { echo "<li>" . $err[$i] . "</li>\n"; } echo "</ul>\n"; show_ccit_form(); exit; } $db = new SQLDB(); $stmt = "INSERT INTO ccits (id, ccit_no, post, post_city, name, salutation, location_id, "; $stmt .= " address_1, address_2, city_id, pincode, email, phone_1, phone_2, fax) "; $stmt .= "VALUES (null, "; $stmt .= ((empty($HTTP_POST_VARS["ccitno"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitno"] ."'")) . ", "; $stmt .= "'" . $HTTP_POST_VARS["ccitpost"] . "', " . $HTTP_POST_VARS["ccitpostcity"] .", "; $stmt .= "'" . $HTTP_POST_VARS["ccitname"] . "', "; $stmt .= ((empty($HTTP_POST_VARS["ccitsalutation"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitsalutation"] ."'")) . ", "; $stmt .= $HTTP_POST_VARS["ccitlocation"] .", "; $stmt .= ((empty($HTTP_POST_VARS["ccitaddress1"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitaddress1"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitaddress2"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitaddress2"] ."'")) . ", "; $stmt .= $HTTP_POST_VARS["ccitcity"] . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitpincode"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitpincode"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitemail"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitemail"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitphone1"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitphone1"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitphone2"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitphone2"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["ccitfax"])) ? "null" : ("'" . $HTTP_POST_VARS["ccitfax"] ."'")); $stmt .= ")"; //echo $stmt; $db->actionQuery($stmt); $last_record = mysql_insert_id(); echo "<br>last record = " . $last_record . "<br>"; return $last_record; } ?> <?php global $HTTP_POST_VARS; global $PHP_SELF; $salutations = new HTMLList("salutations", "citsalutation"); $cit_locations = new HTMLList("locations", "citlocation"); $cit_cities = new HTMLList("cities", "citcity"); $cit_post_cities = new HTMLList("cities", "citpostcity"); ?> <hr> <form name=citform action=<? echo $PHP_SELF ?> method=post> <input type='hidden' name='lastrecord' value='<?php echo $last_record ?>'> <U><b>General Information - CIT<b></U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=33*><COL WIDTH=125*> <THEAD></THEAD> <TBODY> <TR VALIGN=TOP> <TD WIDTH=10%>Post</TD> <TD WIDTH=40%><input type=text name=citpost maxlength=20 value='<?php echo $HTTP_POST_VARS["citpost"]?>'> <?php echo $cit_post_cities->show_list("id", "city", "city", $HTTP_POST_VARS["citpostcity"])?></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Name</TD> <TD COLSPAN=3 WIDTH=90%><?php echo $salutations->show_list("salutation", "salutation", "", $HTTP_POST_VARS["citsalutation"])?> <input type=text name=citname maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["citname"]?>'></TD> </TR> </TBODY> </TABLE> <br> <U><b>Address Details<b></U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=22*><COL WIDTH=136*> <TR VALIGN=TOP> <TD WIDTH=10%>Location</TD> <TD COLSPAN=3 WIDTH=90%><?php echo $cit_locations->show_list("id", "location", "location", $HTTP_POST_VARS["citlocation"])?></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Address</TD> <TD COLSPAN=3 WIDTH=90%><input type=text name=citaddress1 maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["citaddress1"] ?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%><BR></TD> <TD COLSPAN=3 WIDTH=90%><input type=text name=citaddress2 maxlength=200 size=80 value='<?php echo $HTTP_POST_VARS["citaddress2"] ?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>City</TD> <TD WIDTH=28%><?php echo $cit_cities->show_list("id", "city", "city", $HTTP_POST_VARS["citcity"])?></TD> <TD WIDTH=9%>PIN</TD> <TD WIDTH=53%><input type=text name=citpin maxlength=6 size=7 value='<?php echo $HTTP_POST_VARS["citpost"]?>'></TD> </TR> </TABLE> <br><U>Contact Details</U> <TABLE WIDTH=100%> <COL WIDTH=26*><COL WIDTH=72*><COL WIDTH=56*><COL WIDTH=102*> <TR VALIGN=TOP> <TD WIDTH=10%>Phones</TD> <TD COLSPAN=3 WIDTH=90%>1)<input type=text name=citphone1 maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["citphone1"]?>'> 2)<input type=text name=citphone2 maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["citphone2"]?>'></TD> </TR> <TR VALIGN=TOP> <TD WIDTH=10%>Email</TD> <TD WIDTH=28%><input type=text name=citemail maxlength=100 size=50 value='<?php echo $HTTP_POST_VARS["citemail"]?>'></TD> <TD WIDTH=22%>FAX</TD> <TD WIDTH=40%><input type=text name=citfax maxlength=20 size=21 value='<?php echo $HTTP_POST_VARS["citfax"]?>'></TD> </TR> </TABLE> <TABLE WIDTH=100%> <COL WIDTH=85*><COL WIDTH=85*><COL WIDTH=85*> <TR VALIGN=TOP> <TD WIDTH=50% align=center><input class=button type=submit name=save_cit value='Save'> </TD> <TD WIDTH=50% align=center><input class=button type=reset name=cancel value='Cancel'> </TD> </TR> </TABLE> </form> <?php }//end function show_cit_form() ?> <?php function save_cit($last_record) { global $HTTP_POST_VARS; $err = array(); if (empty($HTTP_POST_VARS["citpost"]) || empty($HTTP_POST_VARS["citpostcity"])) $err[] = "CIT Post must be filled in."; if (empty($HTTP_POST_VARS["citname"])) $err[] = "CIT's name must be filled in."; if (empty($HTTP_POST_VARS["citlocation"])) $err[] = "Audit Party's location must be filled in."; if (empty($HTTP_POST_VARS["citaddress1"]) && empty($HTTP_POST_VARS["citaddress2"])) $err[] = "CIT's address must be filled in."; if (empty($HTTP_POST_VARS["citcity"])) $err[] = "CIT's location must be filled in."; if (!(empty($err))) { echo "<ul>\n"; for ($i = 0; $i < count($err); $i++) { echo "<li>" . $err[$i] . "</li>\n"; } echo "</ul>\n"; show_cit_form($last_record); exit; } $db = new SQLDB(); $stmt = "INSERT INTO cits (id, ccit_id, post, post_city, name, salutation, location_id, "; $stmt .= " address_1, address_2, city_id, pincode, email, phone_1, phone_2, fax) "; $stmt .= "VALUES (null, "; $stmt .= $last_record . ", "; $stmt .= "'" . $HTTP_POST_VARS["citpost"] . "', " . $HTTP_POST_VARS["citpostcity"] .", "; $stmt .= "'" . $HTTP_POST_VARS["citname"] . "', "; $stmt .= ((empty($HTTP_POST_VARS["citsalutation"])) ? "null" : ("'" . $HTTP_POST_VARS["citsalutation"] ."'")) . ", "; $stmt .= $HTTP_POST_VARS["citlocation"] .", "; $stmt .= ((empty($HTTP_POST_VARS["citaddress1"])) ? "null" : ("'" . $HTTP_POST_VARS["citaddress1"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["citaddress2"])) ? "null" : ("'" . $HTTP_POST_VARS["citaddress2"] ."'")) . ", "; $stmt .= $HTTP_POST_VARS["citcity"] . ", "; $stmt .= ((empty($HTTP_POST_VARS["citpincode"])) ? "null" : ("'" . $HTTP_POST_VARS["citpincode"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["citemail"])) ? "null" : ("'" . $HTTP_POST_VARS["citemail"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["citphone1"])) ? "null" : ("'" . $HTTP_POST_VARS["citphone1"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["citphone2"])) ? "null" : ("'" . $HTTP_POST_VARS["citphone2"] ."'")) . ", "; $stmt .= ((empty($HTTP_POST_VARS["citfax"])) ? "null" : ("'" . $HTTP_POST_VARS["citfax"] ."'")); $stmt .= ")"; $db->actionQuery($stmt); } ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/41311-problems-in-edit-and-save-script/ Share on other sites More sharing options...
skali Posted March 5, 2007 Share Posted March 5, 2007 Seems like not all of the files that your script requires are not included in this script try checking out your header.php file you should find some files getting included there. Link to comment https://forums.phpfreaks.com/topic/41311-problems-in-edit-and-save-script/#findComment-200156 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.