Jump to content
  • 0
Thejuster

SQL Return 0

Question

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'", [email protected]);
	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
query_sql("SELECT `messaggio` FROM `discordbot` WHERE `id` = 1", [email protected]$);
announce "Discord> " + escape_sql([email protected]$), 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

  • 0

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

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

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.