Jump to content
  • 0

SQL Return 0


Thejuster

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   28
  • Joined:  09/16/18
  • Last Seen:  

Hello i have made this NPC

 

prontera,157,176,7	script	Discord	47,{

        //OnInit:
    while(1) {

	query_sql("SELECT * FROM `discordbot` WHERE `id`='1'", .@item);
	//query_sql("SELECT `messaggio` FROM `discordbot` WHERE `id` LIKE '1'", .@msg);
	announce "Discord> " + escape_sql(.@item[1]),0,0x0965f9;
	sleep 3000;
	
    }
}

 

My Table  discordbot

 


   INT(10)      VARCHAR  (255)
+---------+----------------------+
|   ID    |     MESSAGGIO        |  
+---------+----------------------+
|   1     |    Hello World       |
+---------+----------------------+


On client i see:

screenrAthena002.thumb.jpg.2f98b63c0ee2d33f131aba3df514f97e.jpg

 

for wath reason i dont see my text from database?

 

  • Love 1
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

query_sql("SELECT `messaggio` FROM `discordbot` WHERE `id` = 1", .@item$);
announce "Discord> " + escape_sql(.@item$), 0, 0x0965f9;

and its not advised to use `SELECT * FROM ...` in query, its a common mistake did by alot beginner when they didnt aware of the total columns returned by the script command.

and each array assigned are meant for each individual column.

Link to comment
Share on other sites

  • 2

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  159
  • Reputation:   58
  • Joined:  07/11/14
  • Last Seen:  

alter var int to str: .@item -> .@item$

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   28
  • Joined:  09/16/18
  • Last Seen:  

Not work

i see empty string   

only  

 

"Discord>   "

 

and nothing 

 

prontera,157,176,7	script	Discord	47,{

        //OnInit:
    while(1) {

	
        query_sql("SELECT * FROM `discordbot` WHERE `id`='1'", .@item);
	
	announce "Discord> " + .@item$ ,0,0x0965f9;
	sleep 3000;
	
    }
}

 

and try whit this

 

prontera,157,176,7	script	Discord	47,{

        //OnInit:
    while(1) {

	
        query_sql("SELECT `messaggio` FROM `discordbot` WHERE `id`='1'", .@item);
	
	announce "Discord> " + .@item$ ,0,0x0965f9;
	sleep 3000;
	
    }
}

empty string.

Edited by Thejuster
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  924
  • Reputation:   166
  • Joined:  04/05/13
  • Last Seen:  

Try this

prontera,157,176,7	script	Discord	47,{
	end;
OnInit:
	query_sql("SELECT * FROM `discordbot` WHERE `id`='1'", .@item$);
	announce "Discord> " + escape_sql(.@item$[0]),0,0x0965f9;
	announce "Discord> " + escape_sql(.@item$[1]),0,0x0965f9;
	end;
}

 

Edited by TARTs
Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

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