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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.