Posts: 12
Threads: 4
Joined: Feb 2005
Hi there,
Does anyone know of a free database file (perhaps on an MS site?)
that I can connect to, as I would like to test my (future) SQL code.
Also. How do you get (download) and install MySQL on windows XP
Pro. Is there a MySQL file download free from MS or something?
Regards
John
Posts: 1,272
Threads: 36
Joined: Feb 2003
[Unknown]'s Guide to Installing PHP and MySQL (on Windows):
http://unknown.network32.net/tutorial.basic-server
Posts: 12
Threads: 4
Joined: Feb 2005
Thanks for that. I have just downloaded all 3 to my flash pen and
will take them home later......I will do a quick test on the installation through the internet shop now. If I get any problems
I will let you (the forum) know
Regards
John
Posts: 12
Threads: 4
Joined: Feb 2005
Okay!! I seem to have the .msi installed etc properly via the installation. I then goto the test page:
Open up Notepad, and type in:
<?php
phpinfo();
?>
Now save it, using the filename for your specific server - in IIS and PWS, this is "C:\Inetpub\wwwroot\phpinfo.php" (unless you changed it..) and on Apache it's "C:\Program Files\Apache Group\Apache2\htdocs\phpinfo.php". Remember the quotes, those are important!
What is the above saying? Save that notepad text to where????????? What is the specific server for windows.....what is this person on about?!!!!
Now that you've done that (well I havent)
open up a new window in your favorite web browser. Type in the location bar:
http://localhost/phpinfo.php <-----nothing but error screen :(
Regards
John
Posts: 12
Threads: 4
Joined: Feb 2005
Forgot to add that MYSQL is now here:
C:\Program Files\MySQL\MySQL Server 4.1
I have folders:
bin
data
scripts
share
and .ini files in this (MySQL Server 4.1) folder.
So, again, where is that notepad text save-file going to go?
Regards
John
Posts: 2,771
Threads: 96
Joined: Oct 2003
Have you got apache or some server installed? I would recommend
http://www.apache.org/
Posts: 12
Threads: 4
Joined: Feb 2005
Okay! I am now at home. I used more or less the default settings with the MySQL .msi file and all is okay......I can open mysql via the
MySQL Command Line Client and enter my password and then CREATE DATABASE etc.....one question here. Where is the database stored? I CREATE DATABASE RepairsDB, CREATE TABLE Customers etc. So where is the database RepairsDB on my computer?.....couldn't find it anywhere.
So is MySQL the server or just the client application (tools) needed
to create a local database (where ever it may live?). If it is not the server. How do I connect to a server via the MySQL command line client (or indeed by c code etc). I.e. what would the connection string be for MySQL to talk (connect) to a database somewhere on an MS site (server)?
Basically. What would I (Joe Bloggs) need to do, once he has installed .msi file (mysql) on his computer. Go to the command line client and do....?????????? to connect to someones database.
Regards
John
Posts: 2,765
Threads: 138
Joined: Nov 2002
http://dev.mysql.com/
Query browser helps.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 12
Threads: 4
Joined: Feb 2005
Below is some LCC-Win32 code that I have adapted to my needs.
It opens a .mdb database file on my computer.....all is well.
Question: Would I just change the DSN string to connect to a file
not on my computer? If so, what would the connection string be....There must be at least one file out there that is public, that I can connect to surely. For example. If I want to open a file on my computer I use Open(), Create() etc to work on that file. If I want
to open/retrieve a file from my website I use "Internet (FTP) API".
So if I am now using the code below to open a .mdb file on my computer then surely there must be a way (APIwise) to connect to an outside file on a server.
Regards
John
// Link with odbc32.lib and libmysql.lib
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql.h>
#include <mysql_com.h>
#include <mysql_version.h>
#include <sql.h>
#include <sqlext.h>
#define STG_LEN 256
int main(int argc,char *argv[])
{
SQLRETURN retcode=0;
HENV hEnvironment=SQL_NULL_HANDLE;
HDBC hConnection=SQL_NULL_HANDLE;
HSTMT hStatement=SQL_NULL_HSTMT;
long id=0;
char szString[STG_LEN];
char szSql[STG_LEN];
char szout[STG_LEN];
char connectionString[]="DSN=MS Access Database;DBQ=PersonalDetails.mdb;FIL=MS Access;";
retcode=SQLAllocEnv(&hEnvironment);
if (retcode==SQL_SUCCESS)
{
retcode=SQLAllocConnect(hEnvironment,&hConnection);
if (retcode==SQL_SUCCESS)
{
retcode=SQLDriverConnect(hConnection,NULL,(SQLCHAR *)connectionString,(short)(strlen(connectionString)+1),NULL,0,NULL,SQL_DRIVER_NOPROMPT);
if (retcode==SQL_SUCCESS)
{
retcode=SQLAllocStmt(hConnection,&hStatement);
if (retcode==SQL_SUCCESS)
{
lstrcpy(szSql,"SELECT * FROM Contacts ORDER BY RecordID");
retcode=SQLExecDirect(hStatement,szSql,SQL_NTS);
if (retcode==SQL_SUCCESS)
{
while (retcode=SQLFetch(hStatement)==SQL_SUCCESS)
{
retcode=SQLGetData(hStatement,1,SQL_C_DEFAULT,&id,0,NULL);
if (retcode==SQL_SUCCESS)
{
memset(szString,0,STG_LEN);
retcode=SQLGetData(hStatement,2,SQL_CHAR,szString,STG_LEN,NULL);
if (retcode==SQL_SUCCESS)
{
fprintf(stdout, "ID: %d\tString1: %s\n",id,szString);
}
}
}
}
SQLFreeStmt(hStatement,SQL_DROP);
}
SQLDisconnect(hConnection);
}
SQLFreeConnect(hConnection);
}
SQLFreeEnv(hEnvironment);
}
return 0;
}