Monday, 15 April 2013

Error in php mysql connection using xampp -



Error in php mysql connection using xampp -

i'm trying connect html page using php form mysql database using xampp. html page working fine press submit button page distinct characters appears, can help problem?![php page][1]

html code:

<html> <body> <body bgcolor="black"> <font color="white"> <form action="a.php" method="post"> <center> <h1><font color = "gold"><marquee>welcome online bus booking!!!</h1></marquee> </font color> <h3> first name:<br><input type = "text" name = "fnm"><br> lastly name:<br><input type = "text" name = "lnm"><br> mobile:<br><input type = "text" name = "mob"><br> age:<br><input type = "number" name = "age"><br> source:<input type = "text" name = "src"> destination:<input type = "text" name = "des"><br> <font color="orange">passenger address:<br></font color> street:<br><input type = "text" name = "str"><br> area:<br><input type = "text" name = "area"><br> city:<br><input type = "text" name = "cty"><br> <input type = "submit"> </h3> </center> </form> </body> </html>

php code:

<?php $con=mysqli_connect("localhost","root","","testdb"); if(mysqli_connect_error()) { echo "failed" . mysqli_connect_error(); } $sql="insert exp values('$_post[fnm]', '$_post[lnm]', $_post[mob], $_post[age], '$_post[src]', '$_post[des]', '$_post[str]', '$_post[area]', '$_post[cty]')"; if (!mysqli_query($con,$sql)) { die('error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?>

here, allow me right syntax :

$sql="insert exp values('".$_post['fnm']."','".$_post['lnm']."','".$_post['mob']."', '".$_post['age']."','".$_post['src']."','".$_post['des']."','".$_post['str']."','".$_post['area']."', '".$_post['cty']."')";

php mysql database-connection

No comments:

Post a Comment