Jump to content

Script to output variables for C++ application


TedCopple

Recommended Posts

I have made a script that reads values from MySQL database and "Echo" them.  When I run the script the variables from the DB are printed on the page as they should be. 

 

Now I want to make those variables accessible to my C++ application to read.  I am using WinInet functions to communicate with the script. 

 

Can somebody explain to me what I have to do in my php script be able to access the variables directly.

 

The below script gets the value $var = $_GET['Version']; that is sent from my C++ app.  It then reads from the DB table the Version number entered in the table.  Then compares the version number from my C++ app to the DB version number.  Now I want to make the Version Number from the DB accessible to my C++ app.  I want to be able to get the exact value stored in: $row['VersionNumber']; with my C++ app.

 

<?php
$dbhost = 'host';
$dbuser = 'dbusername';
$dbpass = 'dbpass';

mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
$dbname = 'MyDbsName';
mysql_select_db($dbname);
$query = mysql_query("SELECT * FROM Users");
$var = $_GET['Version'];
while($row = mysql_fetch_array($query))
{
    if($var == $row['VersionNumber'])
    {
    echo $row['VersionNumber'];
    }
}
?>

Hi TedCopple,

 

Are WinInet functions the best way to pull data?

 

What is the purpose of going through PHP to access the database instead of through C++?

 

What about reading the values in an XML format? That way you can still program in PHP and then just output it to a more acceptable format.

 

Something similar to:

...
echo "<version>$versionNumber</version>"
...

Hi TedCopple,

 

Are WinInet functions the best way to pull data?

 

What is the purpose of going through PHP to access the database instead of through C++?

 

What about reading the values in an XML format? That way you can still program in PHP and then just output it to a more acceptable format.

 

Something similar to:

...
echo "<version>$versionNumber</version>"
...

 

No real purpose I suppose.  I am just trying to learn some new things I have never tried before.

 

I finally got my WinInet function working properly today to post data to my website,  so I wanted to give a shot at doing the same thing but in the opposite form.  Right now I am just trying to pull the version number entered on the table,  and in my C++ app,  compare that version with the current version of the C++ app and then log out the result.  Its just a testing phase atm.

 

If you could help me get it in order the way I have described it would much benefit me to explore other methods and such as you have described.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.