PDA

View Full Version : MySQL - Connect question


Adi007
23/04/2015, 09:39 AM
Hello all! If i upload a .db file on my samp server's host, i can use the mysql_connect function to connect to the same server where the samp server is?

like this:
new mysql = mysql_connect("Here my host ip","ftp username from my samp server","name of my .db file","password of the FTP username from my samp server");
Is correctly what i wrote? ^^

BleverCastard
23/04/2015, 09:42 AM
Yes. However, the IP should be "localhost". Username to connect to the database, database name & database password.

Sithis
23/04/2015, 09:56 AM
If your database server is on the same server as your samp server, you can use localhost. If that does not work, ask your host for the correct settings.

Adi007
23/04/2015, 10:05 AM
But is correctly if i write my FTP password / username and not the SQL database username / password ?
And...what;s the difference between .db and .sql file ?

BleverCastard
23/04/2015, 10:57 AM
Not your FTP details. That's for your website. I'm not sure what the difference is between them. I believe .db is client-side!

Adi007
23/04/2015, 04:26 PM
My last question:
Is a good idea to save players' status using .db file which is on same host with server? (in scriptfiles).
http://wiki.sa-mp.com/wiki/Db_open
I would use db_open and other function like db_.... from the link above.
Is a good idea?

AberKane
23/04/2015, 04:30 PM
I would rather start a MySQL server and use the MySQL database.
And for your SQLite database, make sure it's in your "scriptfile" directory.

Adi007
23/04/2015, 04:40 PM
You didn't answered my question. Is good or not to use .db files with the functions like db_....from this http://wiki.sa-mp.com/wiki/Db_open

Sithis
23/04/2015, 05:10 PM
.db files are used with SQLite. Yes, you can open .db with db_open which is built into SA:MP.

For a SQLite database, you do NOT need a login name.

AberKane
23/04/2015, 05:11 PM
That question isn't supposed to be answer as good or bad.
It all depends on many factors, such as "The way you're gonna use them", "What fits your needs" and am not a pro at benchmarking and i don't know which on is better in performances, but you can use it yea. But later you might confront some difficulties and few people will be here to help you along since it's not a common way to use databases, i gave you something to use but as i've seen that's you're question and i hope someone else give a better reply.

TakeiT
23/04/2015, 05:11 PM
Check this out. http://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql

.db file is for sqlite, .sql is for mysql. Convert it with that then upload. Then everything should work. It is okay to use it.

Adi007
24/04/2015, 07:19 AM
Ok, i will try SQLite.
Thanks all for advices.

Some extra help please:
I searched on the internet, but i havn't found.
Let's say that i have this variable: pInfo[playerid][variable]. This variable is a string, how to write in the SQL Query to put a text like "NULL" if the variable is null, like this "".

AberKane
24/04/2015, 01:54 PM
Ok, i will try SQLite.
Thanks all for advices.

Some extra help please:
I searched on the internet, but i havn't found.
Let's say that i have this variable: pInfo[playerid][variable]. This variable is a string, how to write in the SQL Query to put a text like "NULL" if the variable is null, like this "".

Just send it along your query and it should work.

.... %s", pInfo[playerid][string]);

BleverCastard
24/04/2015, 02:50 PM
No. Strings should have ' ' around them. Also, in MySQL you can set default text when creating the columns.

Adi007
28/04/2015, 06:23 AM
No. Strings should have ' ' around them. Also, in MySQL you can set default text when creating the columns.

That's what i need, how to create a default text when creating the columns / rows?