Jump to content

Invalid SQL syntax at line 1?


lucasl

Recommended Posts

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 1

I'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.
Link to comment
https://forums.phpfreaks.com/topic/36311-invalid-sql-syntax-at-line-1/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.