Coonect php to server DB

Started by MEGAMIND, Jul 08, 2018, 07:32 AM

Previous topic - Next topic

MEGAMIND

like the topic says is there anyway to connect through web to server db?

DizzasTeR

Yes by using PHP functions ofcourse.

EK.IceFlake


MEGAMIND

ive been using PHP  alot for search engines etc etc but never figured out how to connect it to vcmp server db

is there any snippet like thing for it

!

#4
Quote from: MEGAMIND on Jul 08, 2018, 09:16 AMive been using PHP  alot for search engines etc etc but never figured out how to connect it to vcmp server db

is there any snippet like thing for it
This link contains complete information of creating a connection to MySQL database using php
https://secure.php.net/manual/en/mysqli.quickstart.connections.php

$mysqli = new mysqli("localhost", "user", "password", "database");


You said you wants to connect to server database using php. Is it MySQL? Because the above will allow you to connect to MySQL database not SQL.

Discord: zeus#5155

MEGAMIND

#5
i have database as .db how is this suppose to help me ? ive tried it but the console says check that ur connection details r okay..so yes they are alright mysql_hostname <- "localhost";
mysql_database <- "Files/DataBase.db";
mysql_username <- "myname";
mysql_password <- "hisname";

function onScriptLoad()
{
   mysqlDB <- mysql_connect( mysql_hostname, mysql_username, mysql_password, mysql_database);
   if( mysqlDB ) print( "[SERVER] Connection to mySQL database successful." );
   else print( "[SERVER] Connection to mySQL failed." );
}


normally i use this to connect to my database when coding shitsdb <- ConnectSQL( "Files/DataBase.db" ); so any refrence guyys?

Error :


Plugins list :


+ Dont tell me to update my every damn thing is updated ;P

if u say i need some other party software too so yea i have it running its xampp

+ i already read some stuff from here too https://forum.vc-mp.org/?topic=444.msg2971#msg2971 although i dont need it cuz been coding with php from idk months/maybe 2-3 years but never connected a game so yea its my first time and its been tough

Xmair

You need to make a mysql account.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MEGAMIND

Quote from: Xmair on Jul 08, 2018, 01:29 PMYou need to make a mysql account.

and where might that be on xampp if u say i already ave a phpmyadmin account, <-- if thats not correct kindly tell me where to make ma acc

Xmair

You need to learn MYSQL, from your replies it clearly shows that you don't know anything about MYSQL.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MEGAMIND

Quote from: Xmair on Jul 08, 2018, 01:56 PMYou need to learn MYSQL, from your replies it clearly shows that you don't know anything about MYSQL.
wtf lol i own a search engine atleast know more then u XD

Xmair

Alright I'm stepping out of this topic after that reply ^.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MEGAMIND

dude if u still know it why not help us who r in need of positive replies XD, dont just leave anyone without helping him/her or atleast refer someone or to something if u cant help ( dont take serious )

MEGAMIND

ok i tried again now but still no clue same problem like previous pic

mysql_hostname <- "127.0.0.1";
mysql_database <- "Files/DataBase.db";
mysql_username <- "root";
mysql_password <- "password123";
mysql_port <- "3306";

function onScriptLoad()
{
db <- mysql_connect( mysql_hostname, mysql_username, mysql_password, mysql_database, mysql_port);
   print("Mysql error: " + mysql_errno());
   if( db ) print( "[SERVER] Connection to mySQL database successful." );
   else print( "[SERVER] Connection to mySQL failed." );
}

vitogta

Quote from: MEGAMIND on Jul 08, 2018, 05:53 PMmysql_database <- "Files/DataBase.db";
db <- mysql_connect( mysql_hostname, mysql_username, mysql_password, mysql_database, mysql_port
Are you trying to use mysql or sqlite?

Sk

Well, You can not use a .db database in mysql, because that ruins the whole point of using mysql in the first place. The correct parameters are already told by @!  If you want to connect your local db with php then, you don't need to switch to mysql, as php has a very vast range to connect with shit lot of things you and I can never imagine. Here is a tutorial which will help you https://www.a2hosting.com/kb/developer-corner/sqlite/connect-to-sqlite-using-php
I don't need to explain any further as you are the "GREAT OWNER OF AN AWESOME SEARCH ENGINE" (probably some nulled script from the internet)