lucasl Posted January 30, 2007 Share Posted January 30, 2007 Hi!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 ” at line 1I'm getting this error. I think it says line one because the code is being eval'd (using wordpress).I looked through and didn't find any problems with my querys.[code]<?php$do = true;$e_id = $_POST["ed_id"];$e_name = $_POST["ed_name"];$e_url = $_POST["ed_url"];$e_description = $_POST["ed_description"];if (empty($e_name)||empty($e_url)||empty($e_description)) { echo 'You didn\'t fill in all the fields, and the site was not edited. Please go back and try again.'; $do = false;}if ($do) {if (!get_magic_quotes_gpc()) { $e_name = stripslashes($e_name); $e_url = stripslashes($e_url); $e_description = stripslashes($e_description); $e_name = addslashes($e_name); $e_url = addslashes($e_url); $e_description = addslashes($e_description);}$dbhost = "localhost";$dbusername = "freesoft_admin";$dbuserpassword = "";$dbname = "freesoft_freesearch";$link = mysql_connect($dbhost, $dbusername, $dbuserpassword);if (!link) { echo mysql_error(); } else { if (!mysql_select_db($dbname)) { echo mysql_error(); }}$query = "UPDATE sites SET name = '$e_name', url = '$e_url', description = '$e_description' WHERE id = $e_id;";$res = mysql_query($query);if (!$res) { echo mysql_error();}mysql_close();echo "The site was successfully edited.";$dbname = "freesoft_wordpress";$link = mysql_connect($dbhost, $dbusername, $dbuserpassword);if (!link) { echo mysql_error(); } else { if (!mysql_select_db($dbname)) { echo mysql_error(); }}}?>[/code]I'm using $do because it I exit or die, the rest of the wordpress page will stop. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 30, 2007 Share Posted January 30, 2007 you have an error in your querythe WHERE statement at the end should read[code]<?php" blah blah blah WHERE id = '$e_id'"; //single ticks around the variable and remove the unwanted semi colon?>[/code] Quote Link to comment 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.