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
https://forums.phpfreaks.com/topic/66972-error/
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
https://forums.phpfreaks.com/topic/66972-error/#findComment-335869
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.