473,414 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

error

40
can smebody plz check my code.on line 111 im checkin if my query has been executed succesfully or not.my query does get executed succesfully,the data goes into the db bt the error message gets displayed i.e "error adding data" although it should display "data added succesfully".can some1 tel me wot i've done wrong?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once "../inc/functions.php";
  3. //require_once "../inc/vars.inc.php";
  4. sessionCheck();
  5. session_start();
  6. $old_sessionid = session_id(); //i've added these lines
  7.  
  8. session_regenerate_id(); //i've added these lines
  9.  
  10. $new_sessionid = session_id(); //i've added these lines
  11.  
  12. function cleanInput($input) {
  13.     $search = array(
  14.         '@<\s*script[^>]*?>.*?<\s*/\s*script\s*>@si',            // Strip out javascript
  15.         '@<\s*[\/\!]*?[^<>]*?>@si',                                                // Strip out HTML tags
  16.         '@<\s*style[^>]*?>.*?<\s*/\s*style\s*>@siU',            // Strip style tags properly
  17.         '@<![\s\S]*?–[ \t\n\r]*>@',
  18.                  '/<img[^>]+\>/i'                                                // Strip multi-line comments
  19.     );
  20.     $output = preg_replace($search, '', $input);
  21.     return $output;
  22. }
  23.  
  24. // ’slashing
  25. function sanitize($input) {
  26.     if (is_array($input)) {
  27.         foreach($input as $var=>$val) {
  28.             $output[$var] = sanitize($val);
  29.         }
  30.     } else {
  31.         $input = @trim($input);
  32.         if (get_magic_quotes_gpc()) {
  33.             $input = stripslashes($input);
  34.         }
  35.         $input  = cleanInput($input);
  36.         $output = mysql_real_escape_string($input);
  37.     }
  38.     return $output;
  39. }
  40.  
  41. function chk_text($str) {
  42.     return ( preg_match("/[`|~|!|@|#|$|%|^|*|=|+|{|}|[|]|:|;|<|>]/", $var) ? true : ( strpos($var, "?") === false ? false : true ) );
  43. }
  44. if($_POST['submit']){
  45.  
  46.     $district = escape($_POST['dis']);
  47.     $taluka = escape($_POST['tal']);    
  48.     $village = escape(trim($_POST['village']));
  49.     $address= escape(trim($_POST['addr']));
  50.     $errCnt = 0;
  51.     echo "$district";
  52.     echo "$taluka";
  53.     echo "$village";
  54.     echo "$address";
  55.  
  56.     if(!$district)
  57.     {$msg[]="please select a district";
  58.         $errCnt++;
  59.     }
  60.     if(!$taluka)
  61.     {$msg[]="please select a taluka";
  62.         $errCnt++;
  63.     }
  64.     /*if($district != '1' || $district != '2'){
  65.  
  66.         $msg[]="please select a district";
  67.         $errCnt++;
  68.     }
  69.     if($taluka == "Select one")
  70.     {
  71.  
  72.     $msg[]="please select a taluka";
  73.     $errCnt++;
  74.     }*/
  75.     if(!$village){
  76.         $msg[] = "Village is required<br />";
  77.         $errCnt++;}
  78.         else
  79.         if(preg_match("/[`|~|!|@|#|$|%|^|*|=|+|{|}|[|]|:|;|<|>]/", $village))
  80.         {
  81.          $msg[] = "No special characters allowed in name<br />";
  82.         $errCnt++;
  83.         }
  84.  
  85.     if(!$address){
  86.         $msg[] = "Address is required";
  87.             $errCnt++;}
  88.             else
  89.         if(preg_match("/[`|~|!|@|#|$|%|^|*|=|+|{|}|[|]|:|;|<|>]/", $address))
  90.         {
  91.          $msg[] = "No special characters allowed in address<br />";
  92.         $errCnt++;
  93.         }
  94.     $sub_id="select subcat_id from subcat where type='".$taluka."'";
  95.     $execute=caseQuery($sub_id);
  96.     $reslt = mysql_fetch_row($execute);
  97.     $sub=$reslt[0];
  98.     echo "$sub";
  99.     if($errCnt == 0){
  100.  
  101.             $sql = 'INSERT INTO `subcat2` (
  102.                             `cat_id` ,
  103.                             `subcat_id` ,
  104.                             `type` ,
  105.                             `vil_name` ,
  106.                             `vil_addr` 
  107.                             )
  108.                             VALUES (
  109.                             "'.$district.'","'.$sub.'", "'.$taluka.'","'.$village.'" ,"'.$address.'"
  110.                             )';
  111.             $dist = caseInsertQuery($sql);
  112.             if($dist)
  113.             {
  114.             $ms= "data added succesfully";
  115.             }
  116.             else
  117.             {
  118.             $ms= "error adding data";
  119.             }
  120.             }
  121.  
  122.             else
  123.             {
  124.             $msgs = addslashes(@implode("<br>",$msg));
  125.             }
  126.         }
  127.  
  128. ?>
  129.  
  130. <?php include_once "admin_templates/case_header.php"; ?>
  131. <html>
  132.  
  133. <head>
  134. <!-- <title>Multiple drop down list box from plus2net</title>
  135.  <link type="text/css" rel="stylesheet" href="../../gpp/inc/jscalender/css/jscal2.css" />
  136.   <link type="text/css" rel="stylesheet" href="../../gpp/inc/jscalender/css/border-radius.css" />
  137.   <link id="skin-win2k" title="Win 2K" type="text/css" rel="alternate stylesheet" href="../../gpp/inc/jscalender/css/win2k/win2k.css" />
  138.   <link id="skinhelper-compact" type="text/css" rel="alternate stylesheet" href="../../gpp/inc/jscalender/css/reduce-spacing.css" />
  139.   <script src="../../gpp/inc/jscalender/js/jscal2.js"></script>
  140.   <script src="../../gpp/inc/jscalender/js/lang/en.js"></script>
  141.  -->
  142.  <SCRIPT>
  143. function frmSubmit(){
  144. var error='';
  145.  
  146.     var dis = document.getElementById('dis').value;
  147.     var tal = document.getElementById('tal').value;
  148.     var vil = document.getElementById('village').value;
  149.     var addr = document.getElementById('addr').value;
  150.     if(dis != 1 || dis != 2){
  151.         error += "district is Required \n";}
  152.         else
  153.         if(dis==1)
  154.         {
  155.         if(tal=="Select one")
  156.         {
  157.         error += "Select taluka \n";
  158.         }
  159.         }
  160.         else if(dis==2)
  161.         {
  162.         if(tal=="Select one")
  163.         {
  164.         error += "Select taluka \n";
  165.         }
  166.         }
  167.  
  168.     if(!vil){
  169.         error += "Panchayat Name is Required \n";
  170.     }
  171.     if(!addr){
  172.         error += "Address is Required \n";
  173.     }
  174.     if(error)    {
  175.         alert(error);
  176.     }else{
  177.         srch_frm.submit();
  178.     }
  179.  
  180. }
  181.  
  182. </script> 
  183. <SCRIPT language=JavaScript>
  184.  
  185. function reload(form)
  186. {
  187. var val=form.dis.options[form.dis.options.selectedIndex].value;
  188. self.location='master.php?dis=' + val ;
  189. }
  190.  
  191. </script>
  192. </head>
  193.  
  194. <body>
  195.  
  196. <?
  197.  
  198. @$dis=$_GET['dis']; 
  199. if(strlen($dis) > 0 and !is_numeric($dis)){ 
  200. echo "Data Error";
  201. exit;
  202. }
  203.  
  204.  
  205.  
  206. $quer2=caseQuery("SELECT DISTINCT dis_name,dis_id FROM district order by dis_name"); 
  207.  
  208. if(isset($dis) and strlen($dis) > 0){
  209. $quer=caseQuery("SELECT DISTINCT tal_name FROM taluka where dis_id=$dis order by tal_name"); 
  210. }else{$quer=caseQuery("SELECT DISTINCT tal_name FROM taluka order by tal_name"); } 
  211.  
  212. ?>
  213.  
  214. <form action="master.php" name="srch_frm" method="post">
  215. <fieldset style="width:20px">
  216. <legend ><b> Search File</b></legend>
  217.   <table width="328" border="1">
  218.   <tr width="320">
  219.   <td >District:</td>
  220.   <td>
  221.   <?php
  222. echo "<select name='dis' onchange=\"reload(this.form)\" ><option value=''>Select one</option>";
  223. while($noticia2 = mysql_fetch_array($quer2)) { 
  224. if($noticia2['dis_id']==@$dis){echo "<option selected value='$noticia2[dis_id]'>$noticia2[dis_name]</option>"."<BR>";}
  225. else{echo  "<option value='$noticia2[dis_id]'>$noticia2[dis_name]</option>";}
  226. }
  227. echo "</select>";
  228. ?>
  229. </td>
  230. </tr>
  231.  
  232. <tr>
  233.       <td>Taluka:</td>
  234.  
  235. <td>
  236. <?php
  237. echo "<select name='tal' ><option value=''>Select one</option>";
  238. while($noticia = mysql_fetch_array($quer)) { 
  239. echo  "<option value='$noticia[tal_name]'>$noticia[tal_name]</option>";
  240. }
  241. echo "</select>";
  242.  
  243.  
  244. ?>
  245. </td>
  246. </tr>
  247.       <td>Panchayat Name:</td>
  248.   <td><input name="village" id="village" type="text" size="15"  value="<?=$_POST['village']?>" /></td>
  249.   </tr>
  250.    <td>Panchayat Address :</td>
  251.   <td><input name="addr" id="addr" type="text" size="15"  value="<?=$_POST['addr']?>" /></td>
  252.   </tr>
  253.   </table>
  254.   <input name="submit" type="submit" value="submit"  >
  255.   <input name="cancel" value="Cancel" type="reset" onClick="reload(this.form)">
  256.  </fieldset>
  257. </form>
  258. <?php
  259. echo "$msgs";
  260. echo "$ms";
  261. //onclick="frmSubmit()"
  262. ?>
  263. </body>
  264.  
  265. </html>
  266.  
Feb 12 '10 #1

✓ answered by Atli

Hey.

Looks like the problem is in the caseInsertQuery function. Have you checked it for errors?
We need to see it if we are to be able to help at all.

P.S.
You don't usually need to post all the code, just the parts that are causing the problem.

2 1266
Atli
5,058 Expert 4TB
Hey.

Looks like the problem is in the caseInsertQuery function. Have you checked it for errors?
We need to see it if we are to be able to help at all.

P.S.
You don't usually need to post all the code, just the parts that are causing the problem.
Feb 12 '10 #2
lisles
40
yes you are right.i didnt have an auto increment column in my table.that was the problem.thanx alot
Feb 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Gregory | last post by:
Hi, One of the disadvantages of using error handling with error codes instead of exception handling is that error codes retuned from a function can be forgotten to check thus leading to...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
0
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.