SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/08/2019, 05:43 AM   #1
Libbyphay
Big Clucker
 
Join Date: May 2017
Posts: 187
Reputation: 0
Default Problem mysql

PHP Code:
[12:43:05] [MYSQL ERROR]: ID1064
[12:43:05] [MYSQL ERROR]: ErrorYou have an error in your SQL syntaxcheck the manual that corresponds to your MariaDB server version for the right syntax to use near 'contacts WHERE cID = '1' LIMIT 10' at line 1
[12:43:05] [MYSQL ERROR]: QuerySELECT IDNameNumber FORM contacts WHERE cID '1' LIMIT 10 
My code:

PHP Code:
public OnPlayerUpdate(playerid)
{
    if(
Calling[playerid] != INVALID_PLAYER_ID)
    {
        new 
query[128];
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT ID, Name, Number FORM contacts WHERE cID = '%d' LIMIT %d"Character[playerid][ID], MAX_CONTACTS);
        
mysql_tquery(SQL_CONNECTIONquery"LoadContact""i"playerid);
    }
    return 
1;
}

forward LoadContact(playerid);
public 
LoadContact(playerid)
{
    for (new 
0cache_num_rows() && MAX_CONTACTS++)
    {
        
cache_get_value_int(i"ID"PhoneInfo[playerid][i][contactID]);
        
cache_get_value_int(i"cID"PhoneInfo[playerid][i][charID]);
        
cache_get_value(i"Name"PhoneInfo[playerid][i][Name], 32);
        
cache_get_value_int(i"Number"PhoneInfo[playerid][i][Number]);

        if(
PhoneInfo[Calling[playerid]][i][Number] == Character[playerid][PhoneNumber])
        {
            
format(PhoneContacted[playerid], 32"%s"GetRoleplayName(playerid));
        }
        else
        {
            
format(PhoneContacted[playerid], 32"Stranger(%d)"Character[playerid][PhoneNumber]);
        }
    }
    return 
1;

How can I fix it?
Libbyphay is offline   Reply With Quote
Old 14/08/2019, 06:09 AM   #2
Exhibit
Big Clucker
 
Join Date: Dec 2015
Location: Pakistan
Posts: 179
Reputation: 22
Default Re: Problem mysql

not an expert in MySQL but isn't this
PHP Code:
new query[128]; 
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT ID, Name, Number FORM contacts WHERE cID = '%d' LIMIT %d"Character[playerid][ID], MAX_CONTACTS); 
supposed to be this?
PHP Code:
new query[128]; 
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT ID, Name, Number FROM contacts WHERE cID = '%d' LIMIT %d"Character[playerid][ID], MAX_CONTACTS); 
__________________
rg-clan.xyz
Exhibit is offline   Reply With Quote
Old 14/08/2019, 06:38 AM   #3
Libbyphay
Big Clucker
 
Join Date: May 2017
Posts: 187
Reputation: 0
Default Re: Problem mysql

Quote:
Originally Posted by Exhibit View Post
not an expert in MySQL but isn't this
PHP Code:
new query[128]; 
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT ID, Name, Number FORM contacts WHERE cID = '%d' LIMIT %d"Character[playerid][ID], MAX_CONTACTS); 
supposed to be this?
PHP Code:
new query[128]; 
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT ID, Name, Number FROM contacts WHERE cID = '%d' LIMIT %d"Character[playerid][ID], MAX_CONTACTS); 
What?
Libbyphay is offline   Reply With Quote
Old 14/08/2019, 06:41 AM   #4
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 299
Reputation: 20
Default Re: Problem mysql

Code:
new query[128]; 
        mysql_format(SQL_CONNECTION, query, sizeof(query), "SELECT ID, Name, Number FROM contacts WHERE cID = %d LIMIT %d", Character[playerid][ID], MAX_CONTACTS); // no ' ' for integer
__________________
Hey guys,
We've just started up our own hosting company and we are offering cheap game hosting. Our SAMP servers start at only $0.50 cents for 32 slots per month, or $1.50 for 64. We have ONE FREE spot left for a first month free subscription for any game host of your choice. We host most many major games such as SAMP, Call of Duty, 7 Days to Die, Minecraft, CounterStrike, ARK: Survival Evolved, and many more!

Cheapest hosting company official site : http://main-hosts.com/

Cheap Hosting Company is looking for an experience staff.

Sign up to our forums and Control Panel and order one of our cheap game servers. First to sign up will receive a free SA:MP server! Join on discord https://discord.gg/J82JgQJ for more information!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 14/08/2019, 07:10 AM   #5
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 662
Reputation: 96
Default Re: Problem mysql

They mean you mistyped FROM to FORM.

Using LIMIT clause without ORDER BY will return different contacts of that player every time.

If you know the number, you can check if it exists in contacts directly and return their contact name or Stranger if no rows found.

You do not reset `Calling[playerid]` after loading so it will keep executing the query.
Calisthenics is offline   Reply With Quote
Old 14/08/2019, 08:06 AM   #6
Libbyphay
Big Clucker
 
Join Date: May 2017
Posts: 187
Reputation: 0
Default Re: Problem mysql

Quote:
Originally Posted by Calisthenics View Post
They mean you mistyped FROM to FORM.

Using LIMIT clause without ORDER BY will return different contacts of that player every time.

If you know the number, you can check if it exists in contacts directly and return their contact name or Stranger if no rows found.

You do not reset `Calling[playerid]` after loading so it will keep executing the query.
Oke I have used

PHP Code:
new query[128]; 
        
mysql_format(SQL_CONNECTIONquerysizeof(query), "SELECT * FROM contacts WHERE cID = '%d' ORDER BY `ID` LIMIT %d"Character[playerid][ID], MAX_CONTACTS); 
It works, but when I delete it in contacts, I can see name it.
Libbyphay is offline   Reply With Quote
Old 14/08/2019, 08:36 AM   #7
Libbyphay
Big Clucker
 
Join Date: May 2017
Posts: 187
Reputation: 0
Default Re: Problem mysql

BUMP
Libbyphay is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Hash Problem & MYSQL Saving Problem Faqahat Scripting Help 3 18/04/2016 11:54 AM
[PLUGIN]: MySQL Problem (MYSQL R39-2) zT KiNgKoNg Scripting Help 11 11/11/2014 06:20 PM
[Mysql problem] Loss of communication with the mysql base SmileyCoder General 0 29/05/2014 03:38 PM
saving system mysql(not mysql problem) martoivanov Scripting Help 0 29/08/2013 03:37 PM
Problem with reading money from MySQL in "Clean, Simple MySQL GM" by L3th4l Dystans Help Archive 1 31/05/2011 09:19 PM


All times are GMT. The time now is 09:02 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.