Error In Sql Syntax Php
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies error 1064 (42000): you have an error in your sql syntax; of this site About Us Learn more about Stack Overflow the company
#1064 - You Have An Error In Your Sql Syntax;
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Mysql Error 1064 (42000)
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a
You Have An Error In Your Sql Syntax Check The Manual That Corresponds To Your Mysql Server Version
minute: Sign up MySQL error - “You have an error in your SQL syntax” up vote 3 down vote favorite The error message I got: 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 ''word','group','selfnote') VALUES ('item','a','note to self')' at line 1 The PHP code is: 1064 error in mysql $toq="INSERT INTO articles ('word','group','selfnote') VALUES ('$ttle','$wrdr','$snote')"; I was trying to find solutins, but they didn't seem to work as echoing gives: INSERT INTO articles ('word','group','selfnote') VALUES ('item','a','note to self') which seems nice to me. What is the problem? php mysql syntax syntax-error mysql-error-1064 share|improve this question edited Jan 17 '15 at 6:50 juergen d 125k21130196 asked Jan 29 '12 at 19:03 axiomer 1,9191025 Have you tried running the exact same query in phpMyAdmin? –Luchian Grigore Jan 29 '12 at 19:06 It gave an error, too. –axiomer Jan 29 '12 at 19:08 2 Obligatory note: mysql_real_escape_string() your data, else Bad Things will happen, e.g. when $snote == "It's simple". –Piskvor Jan 29 '12 at 19:19 add a comment| 4 Answers 4 active oldest votes up vote 6 down vote accepted Use backticks ` instead of quotes ' to escape names. Quotes are string delimiters. $toq="INSERT INTO articles (`word`,`group`, `selfnote`) VALUES ('$ttle','$wrdr','$snote')"; share|improve this answer edited Jan 17 '15 at 6:49 answered Jan 29 '12 at 19:05 juergen d 125k21130196 Thanks, that works! –axiomer Jan 29 '12 at 1
DOMAINS WEB DESIGN WEB DESIGN SERVICES CREATE YOUR OWN WEBSITE SITE HOSTING TOOLS MEET US MEET mysql server version for the right syntax to use near '' at line 1 US ABOUT US PARTNERS & AWARDS BLOG WE'RE HIRING check the manual that corresponds to your mysql server version for the right syntax to use near CONTACT US AMP LOGIN SUPPORT CENTER Search Support Center Product Guides Dedicated Hosting Reseller error 1064 mysql 42000 mysqldump Hosting KnowledgeBase Website Email Domain Names Reseller Billing Community Support Browse Questions Ask a Question User Submitted Articles Education Channels Android BoldGrid cPanel http://stackoverflow.com/questions/9055845/mysql-error-you-have-an-error-in-your-sql-syntax DokuWiki Drupal 7 Drupal 8 Everything Email Joomla 2.5 Joomla 3.1 K2 Magento 1.6 Mambo MediaWiki Moodle Movable Type OpenCart OpenCart 2.0 osCommerce PHP-Fusion PHP-Nuke phpBB phpList Premium Website Builder PrestaShop 1.5 PrestaShop 1.6 SMF Tiki Wiki VirtueMart 3 Web Hosting Manager Website Design WordPress Tools & http://www.inmotionhosting.com/support/website/database-troubleshooting/error-1064 Resources Email Configuration Blacklist Check Visual DNS Lookup Quick Tagger Icon Sets Favicon Generator Bounce Back Parser What is my IP address? >>Website .htaccess (17)Adobe Flash (2)APIs (2)Backup and Restore (15)Billing (8)Browser Issues (2)Connecting to a Database (5)cPanel (26)cPanel Account Management (16)Cron Jobs (4)Cube Cart (2)Database Setup (5)Database Troubleshooting (6)Domain Management (2)Dreamweaver (12)Drush (2)eCommerce (7)Elasticsearch (4)Fantastico (4)File Management (16)File Manager (6)FTP (10)FTP Client Setup (21)General Server Setup / Management (15)Getting Started Guides (18)Ghost (3)Google Tools (21)How To (23)HTML (2)Image Editing (2)IP Addresses (3)iWeb (1)JavaScript (2)Joomla (10)Joomla 2.5 (36)Koken (11)Linux (27)Logaholic (5)Magento (2)Maintaining Your Website (1)Managing Files (7)Microsoft FrontPage (11)Microsoft Publisher (1)ModSecurity (7) MODx (3)New Customers (7)Open Classifieds (1)PCI Compliance (7)PHP (15)PHP Configuration (7)PHP Troubleshooting (6)phpBB (25)phpMyAdmin (10)Premium Website Builder (22)Prestashop (1)Protecting Files (5)Publishing Your Site (2)Python (1)Redirects (4)Restricting Bots (5)Search Engine Optimization (1)Secure Socket Layer (SSL) Tutoria
Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an Apache module Session Security Filesystem Security Database http://php.net/manual/en/pdo.errorinfo.php Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding http://w3schools.invisionzone.com/index.php?showtopic=41524 PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions error in Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation Keyboard you have an Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box PDO::exec » « PDO::errorCode PHP Manual Function Reference Database Extensions Abstraction Layers PDO PDO Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug PDO::errorInfo (PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.1.0)PDO::errorInfo — Fetch extended error information associated with the last operation on the database handle Description public array PDO::errorInfo ( void ) Return Values PDO::errorInfo() returns an array of error information about the last operation performed by this database handle. The array consists of the following fields: Element Information 0 SQLSTATE error code (a five characters alphanumeric identifier defined in the ANSI SQL standard). 1 Driver-specific error code. 2 Driver-specific error message. Note: If the SQLSTATE error code is not set or there is no driver-specific error, the elements following element 0 will be set to NULL.
PDO::errorInfo() only retrieves error information forDetected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. SQL error #1064 Started by Stromgren, Jan 19 2012 04:52 PM Please log in to reply 4 replies to this topic #1 Stromgren Stromgren Newbie Members 21 posts Posted 19 January 2012 - 04:52 PM Hello I have a problem with a query i just created. When i run it, it returns this error: #1064 - 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 '"INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnu' at line 1 "INSERT INTO user (username, password, join_date, virksomhed, email, vej, postnummer, by, telefon) VALUES ('$username', SHA('$password1'), NOW(), '$virksomhed', '$email', '$vej', '$postnummer', '$by', '$telefon')" Can anyone please help me? Thanks in advance Back to top #2 justsomeguy justsomeguy More Human Than Human Moderator 29,451 posts Gender:Male Location:Phoenix Languages:Focusing on PHP and JavaScript Posted 19 January 2012 - 06:41 PM The double quote should not be part of the SQL query. SQL also does not understand PHP variables. Know your history: Babbage | Lovelace | Turing | Hopper | RitchieConTEXT Sublime Text Opera PHP MySQL phpMyAdminUse a debugger: Firefox, IE, Chrome, Safari, or OperaKnow the foundations of computer science: algorithms, machine architectures, data structures, etc. Don't just blindly copy techniques from application to application. Know what you are doing, that it works, and why it works. Don't think you know what the industry will be in five years time or what you'll be doing then, so gather a portfolio of general and useful skills. Try to write better, more principled code. Work to make "programming" more of a professional activity and less of a low-level "hacking" activity (programming is also a craft, but not just a craft). Learn from the classics in the field and the better advanced textbooks; don't be satisfied with the easily digested "how to" guides and online documentation - it's shallow.-- Bjarne StroustrupHe that teaches himself has a fool for a master.-- Benjamin Franklin (paraphrased) Back to top #3 Stromgren Stromgren Newbie Members 21 posts Posted 19 January 2012 - 06:48 PM Thanks for the reply.. The double quotes and variables is showing because i copied fr