CyberShot Posted October 25, 2009 Share Posted October 25, 2009 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? Quote Link to comment Share on other sites More sharing options...
trq Posted October 25, 2009 Share Posted October 25, 2009 Because your query isn't executed any more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.