What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Connecting to a online SQL dabatase

Connecting to a online SQL dabatase
Author: Message:
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. Huh?  Connecting to a online SQL dabatase
Hi everyone :)

How can I connect to a SQL Database online? Do I need to make some DLL for acessing it?

I saw a topic moreless about it, but didn't understand it very well.

Can anyone give a hand?;)
Best Regards,
Joćo Godinho
04-03-2007 06:19 PM
Profile E-Mail PM Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: Connecting to a online SQL dabatase
Personally I would use PHP to connect to an online MySQL database. You can send information to a PHP script from your computer using the server variables $_POST and $_GET. If you understand what I am on about the amount of code required is rather small, and the task itself is easier than it sounds (if you understand what I meant).

If you don't get what I'm on about, I'm sure I can find you some live examples.


Edit: I've made an example for you :).


OK then this is easier than it may appear. First set up your database, customise it, there are no limitations, do as you wish. Next we need to get your script talking to your PHP script:

code:
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open ("POST", "http://www........", true);
http.send ("?sex=male&name=absorbation&address=fakestreet&dob=00.01.01");

Note: Change the url to wherever your script is located. Also &variable='variable data' is what your $_POST variable will be called and the data it will contain.


Finally we need to set up the PHP to communicate with the database:

code:
<?PHP
// Make sure you are connected to the database, and validate the data to make sure people don't abuse your script.
// Getting data sent to the server from the script. The varibles below will be used in the MySQL query.

$sex = $_POST['sex'];
$name = $_POST['name'];
$address = $_POST['address'];
$dob = $_POST['dob'];

// Display the data to make sure it is working.

echo "$sex<br />$name<br />$address<br />$dob";

// MySQL query, make sure you change the query to match your database.

mysql_query("insert into client_details '$sex', '$name', '$address', '$dob'");
?>

This post was edited on 04-03-2007 at 07:21 PM by absorbation.
04-03-2007 07:00 PM
Profile PM Find Quote Report
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. RE: Connecting to a online SQL dabatase
Thank you, you solved my problem. Because I didn't know how to make JScript and PHP work together, I was already starting to make a DLL in VB for acessing it, but I'll try it that way.

Again, many thanks:)
Best Regards,
Joćo Godinho
04-03-2007 08:40 PM
Profile E-Mail PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Connecting to a online SQL dabatase
DON'T LISTEN TO ABSORBATION

if you were to use a php script like that, anyone could just go in and add whatever entries they want -- plus, they could change that query any way they wanted since it isn't properly escaped. i highly recommend you use some sort of mysql client dll.

This post was edited on 04-03-2007 at 09:36 PM by ShawnZ.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
04-03-2007 09:36 PM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Connecting to a online SQL dabatase
Hello

Look at this post http://shoutbox.menthix.net/showthread.php?tid=62...d=696175#pid696175

that connects to a Access database, to connect a mysql one you need to do two things.

to enable the use of mysql you will have to download the odbc connector http://dev.mysql.com/downloads/connector/odbc/3.51.html

then change the db.Open line to

code:
db.Open("DRIVER={MySQL ODBC 3.51 Driver};SERVER=SERVERADDRESS;UID=USERNAME;PWD=PASSWORD;DATABASE=DATABASE;");


with that change you should be able to use the code in the linked post to connect to mysql : >


(Im assuming you meant Mysql, but you can apply this post to any database, you just need to the correct connector and connection string)
[Image: dt2.0v2.png]      Happy Birthday, WDZ
04-04-2007 02:36 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On