Note that there are some explanatory texts on larger screens.

plurals
  1. POSpaces in text stored as underscore in MySQL
    text
    copied!<p>I am storing text in MySQL by sending a request to a url with a function. </p> <p>The url is encoded with %20 as spaces which is all very well but when it is stored in MySQL the spaces are replaced with underscore _ . </p> <p>This is a sentence -> This_is_a_sentence.</p> <p>Is there a way of avoiding this issue?</p> <p>This is the code:</p> <pre><code> function new_experiment_reply($thread_title = '', $raven_thread_id = '', $text = '', $forum_url = '', $raven_forum_id = '') { $email = $this-&gt;session-&gt;userdata('email'); $query = $this-&gt;db-&gt;query("SELECT id FROM fn_users WHERE email='" . $email . "'"); $fn_user_id = $query-&gt;first_row()-&gt;id; $query = $this-&gt;db-&gt;query("SELECT username FROM forum_users WHERE fn_user_id='" . $fn_user_id . "' AND raven_forum_id='" . $raven_forum_id . "'"); $username = $query-&gt;first_row()-&gt;username; $date = date("Y-m-d H:i"); $query = $this-&gt;db-&gt;query('INSERT INTO promo_replies(thread_title, raven_thread_id, text, forum_url, raven_forum_id, date, fn_user_id, username) VALUES("'. $thread_title .'", "'. $raven_thread_id .'", "'. $text .'", "'. $forum_url . '", "'. $raven_forum_id . '", "'. $date . '", "'. $fn_user_id . '", "'. $username . '") '); } </code></pre> <p>The inserted value of variables (as they are seen in Fiddler and as they should be):</p> <pre><code>$thread_title= Facebook%20vs%20Google $raven_thread_id = 123441 $text = This%20is%20a%20sentence $forum_url = domain.com $raven_forum_id = 32 </code></pre> <p>After echoing the query I got the following results:</p> <pre><code>INSERT INTO promo_replies (thread_title, raven_thread_id, text, forum_url, raven_forum_id, date, fn_user_id, username) VALUES ("Facebook_vs_Google", "123441", "This_is_a_sentence", "domain_com", "32", "2012-09-06 06:04", "8", "usssaa") </code></pre> <p>I am prepared to get bashed regarding the code so no worries there. </p>
 

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