problem in database connection
Posted: Fri Oct 17, 2008 2:49 am
Hello Friend
i am very new in php world.pls help me.
i want to coonect mysql database through follwoing code
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$sql="INSERT INTO example (id, data)
VALUES('$_POST[txtId]','$_POST[txtData]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
when i am executing it through debugging it work perfectly. but if i run it in browser id does not work, even not show any message. how can i over it?
thanks.........
i am very new in php world.pls help me.
i want to coonect mysql database through follwoing code
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$sql="INSERT INTO example (id, data)
VALUES('$_POST[txtId]','$_POST[txtData]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
when i am executing it through debugging it work perfectly. but if i run it in browser id does not work, even not show any message. how can i over it?
thanks.........