Jump to content

Error!


unidox

Recommended Posts

I dont know whats wrong, but I keep getting this error:

 

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

 

My file is:

 

<?php
$page = "admins";
$mysql_table = "cp_levels";
require_once("inc/db.inc.php");
require_once ("files/levels.php");
	$selecta = "4.All&3.Roster&2.Staff&1.Admin";
	$checkfields = "title";
	$errors = "Please enter your name!";
	$titles = "Your Name:&Login:&Home:&News:&Roster:&Links:&Leagues:&Matches:&Servers:&Sponsors:&Downloads:&Media:&Demos:&Setting:&Change_Pass:&Users";
	$fields = "title&login&home&news&roster&links&leagues&matches&servers&sponsors&downloads&media&demos&settings&changepass&users";
	$type = "text&select&select&select&select&select&select&select&select&select&select&select&select&select&select&select";
	$size = "40&null&null&null&null&null&null&null&null&null&null&null&null&null&null&null";
	$maxlength = "20&null&null&null&null&null&null&null&null&null&null&null&null&null&null&null";
	$id_type = "level_id";

 if ($_REQUEST['m'] == "4") {
	$choose = explode(".",$_POST['level_id']);
	$access = $choose[1];
	$access2 = "title,login,home,news,roster,links,leagues,matches,servers,sponsors,downloads,media,demos,settings,changepass,users";
	MYSQL_QUERY("UPDATE $mysql_table SET level_id='$access' WHERE $id_type=$id") or die (mysql_error());
	showSuccess('Admin User Level Update');
	header ("Location: index.php?page=admin_users");

} if (!$_REQUEST['m']) {
	getHeader();
	createJSValid($checkfields,$errors);
	createForm($titles,$fields,$type,$size,$maxlength,'4');

} 
?>

 

The db is:

 

  `level_id` int(11) NOT NULL auto_increment,
  `title` varchar(20) NOT NULL default '',
  `login` int(2) NOT NULL default '0',
  `home` int(2) NOT NULL default '0',
  `news` int(2) NOT NULL default '0',
  `roster` int(2) NOT NULL default '0',
  `links` int(2) NOT NULL default '0',
  `leagues` int(2) NOT NULL default '0',
  `matches` int(2) NOT NULL default '0',
  `servers` int(2) NOT NULL default '0',
  `sponsors` int(2) NOT NULL default '0',
  `downloads` int(2) NOT NULL default '0',
  `media` int(2) NOT NULL default '0',
  `demos` int(2) NOT NULL default '0',
  `settings` int(2) NOT NULL default '0',
  `pass` int(2) NOT NULL default '0',
  `users` int(2) NOT NULL default '0',
  PRIMARY KEY  (`level_id`)
) TYPE=MyISAM  AUTO_INCREMENT=38 ;

Link to comment
Share on other sites

First off, try putting quotes around the variables in your query.

MYSQL_QUERY("UPDATE $mysql_table SET level_id='$access' WHERE '$id_type'='$id'") or die (mysql_error());

 

If that doesn't work, try using mysql_real_escape_string() on $acess, $id_type, and $id before you use them in your query.

Link to comment
Share on other sites

... SET level_id='$access' WHERE $id_type=$id ...

 

According to the database table schema you posted, level_id is auto-incrementing PK so you shouldn't even be thinking of setting its value, and id_type is not a field in the table.  Something's not right here.

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.