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? Link to comment https://forums.phpfreaks.com/topic/178910-solved-can-you-explain-this/ 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. Link to comment https://forums.phpfreaks.com/topic/178910-solved-can-you-explain-this/#findComment-943882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.