Jump to content

[SOLVED] error in your SQL syntax


irkevin

Recommended Posts

i have an sql which looks like below

 

<?php
//require the config file
require ("config.php");

//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());

//build and issue the query
$sql ="SELECT * FROM banned WHERE type = 'user'";
$result = @mysql_query($sql,$connection) or die(mysql_error());

while ($sql = mysql_fetch_object($result)) 
{
$banned = $sql -> no_access;

echo "<option value=\"$banned\">$banned</option>";
}
?>

 

but when it executes, i get this message, what does it mean?

 

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 '(no_access, type) WHERE no_access = 'tester'' at line 1

Link to comment
Share on other sites

$lift_user = "DELETE FROM banned (no_access, type) WHERE no_access = '$_POST[lift_user_ban]'";
	$result = @mysql_query($lift_user,$connection) or die(mysql_error());
	$msg .= "The Ban for user $_POST[lift_user_ban] has been lifted.<br>";

 

what about this one?

Link to comment
Share on other sites

Yeah.

 

You dont need to define the fileds within a DELETE query. It automatically deletes the entire row.

 

$lift_user = "DELETE FROM banned WHERE no_access = '{$_POST['lift_user_ban']}'";

 

ps: You realy ought sanatise your incomming data. Don't ever stick a $_POST variable directly within your query.

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.