Guber-X Posted June 26, 2012 Share Posted June 26, 2012 im just making a simple contact form to submit to my database. it always comes up with this error. Error, insert query failed: 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 '@hotmail.com, 'Test Msg')' at line 1 my form involves these input boxes in the same order and also what I entered into those boxes Name: Shane Phone: 2502501234 Email: [email protected] Msg: Test Msg for my understanding its not taking the "Email" input box correctly or something. heres my code... <?php if (isset($_POST['submit'])) { $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $msg = $_POST['msg']; $querys = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', $phone, $email, '$msg')"; mysql_query($querys) or die("Error, insert query failed: " . mysql_error()); echo '<br /><br />Thank You!'; } else { echo '<form method="post">', '<table>', '<tr>', '<td>Name: </td>', '<td>', '<input type="text" name="name" id="name">', '</td>', '</tr>', '<tr>', '<td>Phone #:</td>', '<td>', '<input type="tel" name="phone" id="phone">', '</td>', '</tr>', '<tr>', '<td>Email:</td>', '<td>', '<input type="email" name="email" id="email">', '</td>', '</tr>', '<tr>', '<td class="msg">Message:</td>', '<td>', '<textarea id="msg" name="msg" rows="10" cols="40"></textarea>', '</td>', '</tr>', '<tr>', '<td rowspan="2">', '<input type="submit" value="Submit" id="submit" name="submit">', '</td>', '</tr>', '</table>', '</form>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/264779-issues-_post-email-to-database/ Share on other sites More sharing options...
Guber-X Posted June 26, 2012 Author Share Posted June 26, 2012 holy hell im blind... i found my error... $querys = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', $phone, $email, '$msg')"; i was missing some quotations by the $phone and $email... lol. should be like this $querys = "INSERT INTO contact (name, phone, email, msg) VALUES ('$name', '$phone', '$email', '$msg')"; Quote Link to comment https://forums.phpfreaks.com/topic/264779-issues-_post-email-to-database/#findComment-1356988 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.