Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Print errors on inserting, deleting and updating
18/11/2012
03:35
Avatar
sebastiancb
COlombia
Member
Members
Forum Posts: 23
Member Since:
05/09/2011
sp_UserOfflineSmall Offline

This is my edit.php:

<?php
$op=$_POST['oper'];
$bd = mysql_connect("localhost","root","") or die("Connection Error: " . mysql_error());
mysql_select_db("depselect") or die("Error conecting to db.");

if($op=="add"){
    $id_p=$_POST['idp'];
    $name_p=$_POST['name'];
    $id_ct=$_POST['namect'];
    $id_cy=$_POST['namecy'];
$sql="INSERT INTO people(idp, name,country,city) VALUES ($id_p,'$name_p',$id_ct,$id_cy)";
$rs=mysql_query($sql);
if($rs==false) {
    if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") )
   { header("Content-type: application/xhtml+xml;charset=utf-8"); }
   else { header("Content-type: text/xml;charset=utf-8"); }
    echo "<?xml version='1.0' encoding='utf-8'?>";
    
               echo "<xml>
                      <error>
                        error message
                      </error>
                     </xml>";}
else
echo "registro guardado";
}

if($op=="edit"){
}

if($op=="del"){
}

mysql_close($bd);
?>

and this is my index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ejemplo</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="grid.locale-es.js"></script>
<script type="text/javascript" src="jquery.jqGrid.min.js"></script>
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="ui.jqgrid.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
$(document).ready(function(){
//————————————–
function load_countries(){
var countries;
    $.ajax({
           url: 'load_countries.php',
           type: 'get',
           async: false,
           success: function(data){
            countries=data;        
           }
        });
    return countries;
}
//————————————–

$("#list3").jqGrid({ url:'list.php',
datatype: "xml",
colNames:['Id','name','country','city'],
colModel:[{name:'idp',index:'idp', width:100,sortable:true,editable:true},
          {name:'name',index:'name', width:100,sortable:false,editable:true,sortable:true},
          {name:'namect',index:'namect', width:150,sortable:false,editable:true,sortable:true,
               edittype:'select',editoptions: {value:load_countries(),
                                                   dataEvents:[{type: 'change', fn: function(e) {
                                                                     var thisval = $(e.target).val();
                                                                      $.get('load_cities.php?id_country='+thisval,
                                                                      function(data)
                                                                      { $("select#namecy").html(data);
                                                                      }); // end get
                                                               }//end func
                                                             } // end type
                                                            ] // dataevents
                                              } // edit option
                                             },
          {name:'namecy',index:'namecy',editable: true,edittype:"select",editoptions:{dataUrl:'load_cities.php?id_country=1'}}],
        recreateForm:true,
        rowNum:10,
        rowList:[10,20,30],
        pager: '#pager3',
        sortname: 'idp',
        viewrecords: true,
        savekey: [true,13],
        sortorder: "asc",
        xmlReader: {root: "rows",
                            repeatitems : true,
                           id: "[id]"                           
                          },
        caption: "Students",
        height:'100%',
        editurl:"edit.php",
        onSelectRow: function(rowid) {

                    if (rowid != null) {
                        var record = $("#list3").getRowData(rowid);
                        var pgm="load_cities.php?country="+record.namect;
                        $("#list3").setColProp('namecy',{editoptions:{dataUrl:pgm}});
                        }
                    }
});

//————————————–
$("#list3").jqGrid('navGrid','#pager3',{edit:true,add:true,del:true,search:true},{savekey: [true,13]},{viewPagerButtons:false,recreateForm:true});
//**********************************************************************************
});
</script>
</head>
<body>
 <table id="list3"></table>
 <div id="pager3"></div>
</body>
</html>

How do I show the generated error when I am trying to save a duplicated row in my table, I someone can help me, I thank.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
56 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information