Jump to content

Database Connectivity Problem


dhivyasp

Recommended Posts

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

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" /> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.