Note that there are some explanatory texts on larger screens.

plurals
  1. POremove links from mysql insert statement?
    primarykey
    data
    text
    <p>I wonder if someone could please help, I am running a MySQL insert query, so when a user fills in a form it inserts the content into the database. However, I am trying to make it so that I can remove/block links (URLs) from being inserted.</p> <p>I am trying this, but I'm new to MySQL and am not able to get it working, I'm not sure I'm doing it right, I'd be grateful if someone could help.</p> <p>Thanks in advance,</p> <pre><code>&lt;?php ob_start(); ?&gt; &lt;?php // check if the review form has been sent if(isset($_POST['review_content'])) if(isset($_POST['review_recipient'])) { $content = $_POST['review_content']; $review_recipient = $_POST['review_recipient']; //We remove slashes depending on the configuration if(get_magic_quotes_gpc()) { $content = stripslashes($content); $review_recipient = stripslashes($review_recipient); } //We check if all the fields are filled if($_POST['review_content']!='') if($_POST['review_recipient']!='') { { $forbidden = array('&lt;[\w.]+@[\w.]+&gt;', '&lt;\w{3,6}:(?:(?://)|(?:\\\\))[^\s]+&gt;', '#&lt;.*?&gt;([^&gt;]*)&lt;/a&gt;#i'); $matches = array('****', '****', '****'); $post = preg_replace($forbidden, $matches, $post); $sql = "INSERT INTO ptb_reviews (id, from_user_id, from_guest, to_user_id, content) VALUES (NULL, '-1', '".$review_recipient."', '".$profile_id."', '".$content."');"; mysql_query($sql, $connection); $_SESSION['message']="&lt;div class=\"infobox-wallpost\"&gt;&lt;strong&gt;Thank You&lt;/strong&gt; - Your review has been sent and is awaiting approval.&lt;/div&gt;&lt;div class=\"infobox-close4\"&gt;&lt;/div&gt;"; header("Location: {$_SERVER['HTTP_REFERER']}"); } } } } } ?&gt; </code></pre> <p>updated:</p> <p>ok so I'm trying to do it like this but its still allowing the url to be displayed</p> <pre><code>&lt;?php ob_start(); ?&gt; &lt;?php // check if the review form has been sent if(isset($_POST['review_content'])) if(isset($_POST['review_recipient'])) { $content = $_POST['review_content']; $review_recipient = $_POST['review_recipient']; //We remove slashes depending on the configuration if(get_magic_quotes_gpc()) { $content = stripslashes($content); $review_recipient = stripslashes($review_recipient); $regex = "/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?/"; $replacement = "[blocked url]"; $review_recipient = reg_replace($regex,$replacement,$_POST['review_recipient']); $profile_id = intval($_POST['profile_id ']); //dont know how you get this $content = reg_replace($regex,$replacement,$_POST['review_content']); } //We check if all the fields are filled if($_POST['review_content']!='') if($_POST['review_recipient']!='') { { $sql = "INSERT INTO ptb_reviews (id, from_user_id, from_guest, to_user_id, content) VALUES (NULL, '-1', '".$review_recipient."', '".$profile_id."', '".$content."');"; mysql_query($sql, $connection); $_SESSION['message']="&lt;div class=\"infobox-wallpost\"&gt;&lt;strong&gt;Thank You&lt;/strong&gt; - Your review has been sent and is awaiting approval.&lt;/div&gt;&lt;div class=\"infobox-close4\"&gt;&lt;/div&gt;"; header("Location: {$_SERVER['HTTP_REFERER']}"); } } } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload