Jump to content

Question

Posted

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

4 answers to this question

Recommended Posts

  • 0
Posted
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.

  • 0
Posted (edited)

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
  • 0
Posted (edited)

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...