dhivyasp Posted April 1, 2007 Share Posted April 1, 2007 Hi Everyone, Am beginner in PHP, and am using WAMP. While connecting the database my script is not displaying any error and also not store the information to the database. Below is the code: <?php ob_start(); ?> <html> <head> <script language = "text/javascript"> function dovalid() { if(document.frm.empno.value.length == "0") { alert ("Please enter the Emp No"); document.frm.empno.focus(); return false; } else { document.frm.submit(); } } </script> </head> <body> <form name = frm action = <?php echo $_SERVER['PHP_SELF']; ?> method = "post"> Enter the Employee Number : <input type = text name = empno> <br> Enter the Employee Name : <input type = text name = empname> <br> <input type = submit value = "save" onclick = "dovalid()"> </form> </body> </html> <?php $con = @mysql_connect("192.168.0.1", "root", "abcdef") or die(mysql_error()); $db = @mysql_select_db("emp", $con) or die(mysql_error()); if (isset ($_POST['empno']) or isset ($_POST['empname'])) { $qry = "insert into empdet (empno, empname) values (".$_POST['empno'].", '".$_POST['empname']."')"; $res = @mysql_query($qry) or die(mysql_error()); if($res >0) { header("phpinfo.php"); } } @mysql_close($con); ob_end_flush(); ?> Kindly advise me is there any problem with my connectivity and also let me know may i have to include the path name while connecting the database. Have a Good Day!!! Thanks!!! Link to comment https://forums.phpfreaks.com/topic/45116-database-connectivity-problem/ Share on other sites More sharing options...
MadTechie Posted April 1, 2007 Share Posted April 1, 2007 i think its more of a HTML problem change Enter the Employee Number : <input type = text name = empno> Enter the Employee Name : <input type = text name = empname> to Enter the Employee Number : <input type="text" name="empno" /> Enter the Employee Name : <input type="text" name="empname" /> Link to comment https://forums.phpfreaks.com/topic/45116-database-connectivity-problem/#findComment-219025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.