Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting e-mail address in MySQL using PHP
    primarykey
    data
    text
    <p>The last few hours I've spent in struggling with a quite ridiculous error. Simply what I'm making a registration form. User need to enter a e-mail and the mail will be stored in a mysql table. (I have to warn you - please disregard the security issue, the whole thing is just a exercise). But I constantly get the following error from the sql:</p> <blockquote> <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com,blqh2@gmail.com,1)' at line 1</p> </blockquote> <p>The html is as follows:</p> <pre><code> &lt;form method="post" action="createnew.php"&gt; &lt;label &gt;user name&lt;/label&gt; &lt;input name="login_id"&gt;&lt;/br&gt; &lt;label&gt;password&lt;/label&gt; &lt;input name="password" password&gt;&lt;/br&gt; ...some more stuff... &lt;label&gt;Privet e-mail&lt;/label&gt; &lt;input name="prv_email"&gt;&lt;/br&gt; &lt;label&gt;Public e-mail&lt;/label&gt; &lt;input name="pub_email"&gt;&lt;/br&gt; &lt;label&gt;Are you a reseller&lt;/label&gt; &lt;input type="checkbox" name="reseller"&gt;&lt;/br&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre> <p>Then comes the PHP:</p> <pre><code>$login_id=$_POST['login_id']; $password=$_POST['password']; ...some more stuff... $pub_email=$_POST['pub_email']; echo $prv_email; echo $pub_email; if (array_key_exists('reseller',$_POST)) { $reseller=1; } else { $reseller=0; } $sql="INSERT INTO users". "(login_id,password,usr_phone,region,prv_email,pub_email,reseller)". "VALUES". "($login_id,$password,$usr_phone,$region,$prv_email,$pub_email,$reseller)" </code></pre> <p>And finally the MySQL formatting for the mail field(practically they prv_email and pub_email are with the same formatting)</p> <pre><code> Field | Type | Collation ----------|--------------|------------------- pub_email | varchar(255) | utf8_general_ci </code></pre> <p>I did try a lot off stuff but nothing seems to work. It always crushes at @. and one more thing - I'm running this who code on localhost(using WAMP), not sure if this have anything to deal with the problem. Please let me know if you need any other information and thanks a lot.</p>
    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.
 

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