Jump to content

[SOLVED] can you explain this?


CyberShot

Recommended Posts

my code works. But when I remove this

 

if (!mysql_query($sql,$con))
  {
	 die('Error: ' . mysql_error());
  }

 

include('connection.php');
$pattern = '/[A-Za-z]+/';

if(isset($_POST['name']) && preg_match($pattern, $_POST['name']))
{
$name = $_POST['name'];
$sql="INSERT INTO mytable (names) VALUES ('$name')";
header("Location: http://localhost/php_sandbox/dbtest/index.php");
}
else
{
echo "You must only use letters a to z";

}

if (!mysql_query($sql,$con))
  {
	 die('Error: ' . mysql_error());
  }


mysql_close($con);

 

the code stops working. Why would it stop working?

Link to comment
https://forums.phpfreaks.com/topic/178910-solved-can-you-explain-this/
Share on other sites

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.