Hello all,
I have a problem with inserting text with quotes, or html code in to a MYSql Database. I've been trying to create my own content management system, and unfortunately I've come accross a problem, the script below works perfectly if I'm not inserting any quotes (" ") or html tags. I'm wondering if I'm doing something wrong here? The field type where all of the content will go was set up as a blob type.
I have the following PHP code:
Thanks for any help!
I have a problem with inserting text with quotes, or html code in to a MYSql Database. I've been trying to create my own content management system, and unfortunately I've come accross a problem, the script below works perfectly if I'm not inserting any quotes (" ") or html tags. I'm wondering if I'm doing something wrong here? The field type where all of the content will go was set up as a blob type.
I have the following PHP code:
Code:
<?php $conn = connect(); $action = $_GET['a']; $id = $_GET['id']; switch($action) { case 'delete': $sql = "DELETE FROM article WHERE id='$id'"; if(mysql_query($sql)) { echo "<script type='text/javascript'> alert('Article Deleted'); </script>"; header("Location: article.php"); } break; case 'add': if(isset($_POST['submit'])) { $title = $_POST['title']; $text = $_POST['content']; $sql = "INSERT INTO article (articleTitle,articleContent) values ('$title','$text')"; if(mysql_query($sql)) { echo "<script type='text/javascript'> alert('Article Added'); </script>"; header("Location: article.php"); } } break; case 'edit': if(isset($_POST['submit'])) { $title = $_POST['title']; $text = $_POST['content']; $sql = "UPDATE article SET articleTitle='$title',articleContent='$text' WHERE id='$id'"; if(mysql_query($sql)) { echo "<script type='text/javascript'> alert('Article Updated'); </script>"; header("Location: article.php"); } } break; } ?>
Comment