• You are not logged in. | Login

Post a reply

  • Index
  •  » Help me!
  •  » Queries are executed only seperately, they don't work together

January 17, 2007 6:44 am

purplebean
Member
Ranks

Queries are executed only seperately, they don't work together

CREATE TABLE `uri8y_ban_list`
( 
`ban_id` mediumint(8) UNSIGNED NOT NULL auto_increment,
`ban_type` VARCHAR(15) NOT NULL DEFAULT '',
`ban_value` VARCHAR(15) NOT NULL DEFAULT '',
`ban_reason` TEXT NOT NULL,
PRIMARY KEY (`ban_id`)
);
 
CREATE TABLE `uri8y_blocks`
(
`block_id` mediumint(8) UNSIGNED NOT NULL auto_increment,
`block_position` VARCHAR(50) NOT NULL DEFAULT '',
`block_title` VARCHAR(100) NOT NULL DEFAULT '',
`block_show_title` BOOL,
`block_type` VARCHAR(4) NOT NULL DEFAULT '',
`block_content` LONGTEXT NOT NULL,
`block_access` TINYINT(4) NOT NULL,
`block_groups` LONGTEXT NOT NULL,
`block_enabled` BOOL,
`block_expire` BOOL,
`block_expire_date` INT(11) NOT NULL,
`block_expire_action` BOOL,
PRIMARY KEY (`block_id`)
);

If I use them together there appears an 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 '; CREATE TABLE `uri8y_blocks` ( `block_id` medium

I can't understand why they don't work?
Does anybody know?


 

 

January 17, 2007 6:47 am

mambojim
Member
Ranks

Re: Queries are executed only seperately, they don't work together

Why do you think that they should work together?


 

 

January 17, 2007 6:56 am

purplebean
Member
Ranks

Re: Queries are executed only seperately, they don't work together

Shouldn't they? I think they must work.
Do you want to say that mysql_query("CREATE TABLE `name` (...); CREATE TABLE `name_2` (...);"); isn't right?
Here the full code:

// SQL class
class sql 
{ 
... 
// query function
 
function query($query = '') 
{ 
  if($result = @mysql_query($query) return $result; 
  else  
  { 
    echo "Query fail. MySQL return: ".mysql_error(); 
   // ... 
   //logging
   // ... 
   return false; 
  } 
} 
... 
} 
//actually what I want to execute:
$sql->query("both queries" says that it can't use them both ; CREATE TABLE `uri8y_blocks` ( `block_id` medium, 
echo "<hr>"; 
$sql->query("first query"); // ececutes 
echo "<hr>"; 
$sql->query("second query"); // executes
 
I can't use queries seperately because queries are included to the file:
 
CREATE TABLE `{prefix}ban_list` 
(  
    `ban_id` mediumint(8) UNSIGNED NOT NULL auto_increment, 
    `ban_type` VARCHAR(15) NOT NULL DEFAULT '', 
    `ban_value` VARCHAR(15) NOT NULL DEFAULT '', 
    `ban_reason` TEXT NOT NULL, 
    PRIMARY KEY (`ban_id`) 
); 
 
CREATE TABLE `{prefix}blocks` 
( 
    `block_id` mediumint(8) UNSIGNED NOT NULL auto_increment, 
    `block_position` VARCHAR(50) NOT NULL DEFAULT '', 
    `block_title` VARCHAR(100) NOT NULL DEFAULT '', 
    `block_show_title` BOOL, 
    `block_type` VARCHAR(4) NOT NULL DEFAULT '', 
    `block_content` LONGTEXT NOT NULL, 
    `block_access` TINYINT(4) NOT NULL, 
    `block_groups` LONGTEXT NOT NULL, 
    `block_enabled` BOOL, 
    `block_expire` BOOL, 
    `block_expire_date` INT(11) NOT NULL, 
    `block_expire_action` BOOL, 
    PRIMARY KEY (`block_id`) 
);

 

 

January 17, 2007 7:00 am

mmwfan
Member
Ranks

Re: Queries are executed only seperately, they don't work together

Why are you trying to put 2 queries into one?
Why can't you write like that:

//first query
$sQuery="";
mysql_query($sQuery);
//second query
$sQuery="";
mysql_query($sQuery);

 

 
  • Index
  •  » Help me!
  •  » Queries are executed only seperately, they don't work together
  • Actions
  • Top