php - mysql syntax problem -


I am trying to display information from a mysql line on this page. I am using $ _GET, because the ID is included in the link of the page: www.example.com/page.php?id=1 but it returns this error:

error : You have an error in your SQL syntax;

To use '=' 1 'near the code given below, check the manual for the correct syntax that matches your MySQL server version

Does anyone Do you know how to fix this? :

  & lt ;? Php $ username = "xxx"; $ Password = "xxx"; $ Database = "xxx"; Mysql_connect (local host, $ user name, $ password); @ Mysql_select_db ($ database) or die ("Unable to select database"); Included 'library / config.php'; Included 'library / opendb.php'; ("$ Id = '{$ _GET [' id ']) {$ id =" {$ _GET [' id ']) {$ id =' {$ _GET ['id']) {$ query = "SELECT id, title, content, contactname, contact email, contact number" ]} ''; $ Result = mysql_query ($ query) or die ('error:' mysql_error ()); List ($ id, $ title, $ content, $ contactname, $ contactemail, $ contactnumber) = mysql_fetch_array ($ result, MYSQL_NUM); $ Content = htmlspecialchars ($ content); } If (isset ($ _ POST ['update'])) {$ id = $ _POST ['id']; $ Heading = $ _POST ['title']; $ Content = $ _POST ['content']; $ Contactname = $ _POST ['Contact name']; $ Contactemail = $ _POST ['Contact Email']; $ Contactnumber = $ _POST ['Contact Number']; If (! Get_magic_quotes_gpc ()) {$ title = addlashes ($ heading); $ Content = addslashes ($ content); $ Contactname = addslashes ($ contactname); $ Contactemail = addlashes ($ contactmail); $ Contactnumber = addlashes ($ contactnumber); } // Update the article in the database $ query = "UPDATE vacancies SET title = '$ title', content = '$ content', contactname = '$ contactname', contactemail = '$ contactemail', contactnumber = '$ contactnumber' ". "WHERE id = '$ id'"; Mysql_query ($ query) or die ('error:'. Mysql_error ()); // Then remove the cache file $ cacheDir = dirname (__ FILE__). '/ Cache /'; $ Cachefile = $ cachedriver '_' $ _GET ['id'] '.html'; @unlink ($ cacheFile); // and index.html also because file list // is changed @unlink ($ cacheDir 'index.html'); Echo "& lt; b & gt; Job entry: '$ title' updated & lt; / b & gt;"; // Now we will display $ title & amp; Content // Dismiss any slash $ title = strip slash ($ title); $ Content = strips slash ($ content); $ Contactname = StripSlash ($ contactname); $ Contactemail = StripSearch ($ Contact Mail); $ Contactnumber = StripSash ($ contactnumber); } 'Library / Closed' included. PPP; ? & Gt;  

Try it out:

  $ query = " Select ID, Title, Content, Contact Name, Contact Email, Contact Number ". "From empty positions" "WHERE id = '". $ _ GET ['id']. ' '' ';  

I always try to leave the variable outside my strings, just add them with periods, I think it eliminates much confusion.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -