AT2k Design BBS Message Area
Casually read the BBS message area using an easy to use interface. Messages are categorized exactly like they are on the BBS. You may post new messages or reply to existing messages!

You are not logged in. Login here for full access privileges.

Previous Message | Next Message | Back to Scripts Only! (Code Only)  <--  <--- Return to Home Page
   Networked Database  Scripts Only! (Code Only)   [24 / 68] RSS
 From   To   Subject   Date/Time 
Message   Steve Winn    bigjoe11a   Mysql and Vscript   December 4, 2006
 6:37 PM  

Re: Mysql and Vscript

> Can any one make a vscript that can access a mysql database.

Instead of writing your script I did write a quick PHP script that should let
you interface with MySQL using the commandline (including VScript if desired).
You can probably do this many other ways but I like PHP. Note: I have only
performed limited testing so it might work or might not.

-- BEGIN SCRIPT (vadvmysql.php) --
<?php
// Quick script to interface VADV with MySQL.

// Usage:
// php.exe -n -f vadvmysql.php <query>

// Modify these variables.
$DBNAME = 'database';
$DBUSER = 'username';
$DBPASS = 'password';

$MYSQL_HOST = 'localhost';

// Everything below should not be edited.

@$SQL_CONNECTION = mysql_connect($MYSQL_HOST, $DBUSER, $DBPASS);
if (!$SQL_CONNECTION) {
    die('Could not connect.';);
}

$sql_db = mysql_select_db($DBNAME, $SQL_CONNECTION);

$query = '';
for ($i = 1; $i < count($_SERVER['argv']); $i++) {
    $query .= $_SERVER['argv'][$i] . ' ';
}

@$result = mysql_query(trim($query), $SQL_CONNECTION);
if (!$result) {
    die('Invalid result.';);
}

while ($object = mysql_fetch_object($result)) {
    foreach ($object as $line) {
        print $line . ';';
    }
    print "\r\n";
}

?>
-- END SCRIPT --

Then in VScript you can do something like this:
LET Q0 = "SELECT * FROM vadvextra"
LET Q1 = "PHP.EXE -n -f vadvmysql.php " % Q0 % " > RESULTS.TXT"
SHELL Q1

OPEN "RESULTS.TXT", "I"
READ L0
CLOSE

PRINT L0

Take note that the above php script will print the data in a semicolon
delimited format and one line per result. In other words you will need to write
a VScript sub to break apart the results and get whatever data you need. Or,
you could just edit the php script above to have it do whatever you want. This
is only an example so don't ask for support :)

Steve


--
[AT2k] -- Your VBBS/VADV Support Center -- [www.at2k.org] -- [bbs.at2k.org]
  Show ANSI Codes | Hide BBCodes | Show Color Codes | Hide Encoding | Hide HTML Tags | Show Routing
Previous Message | Next Message | Back to Scripts Only! (Code Only)  <--  <--- Return to Home Page

VADV-PHP
Execution Time: 0.0165 seconds

If you experience any problems with this website or need help, contact the webmaster.
VADV-PHP Copyright © 2002-2024 Steve Winn, Aspect Technologies. All Rights Reserved.
Virtual Advanced Copyright © 1995-1997 Roland De Graaf.
v2.1.241108