Re: I need help with this database

From: Max Nokhrin (mno11_at_lycos.com)
Date: 11/30/03


Date: Sun, 30 Nov 2003 10:47:38 -0500

If you're not sure if the DB exists or not, you can try opening it first
and if you get an error there, then create it.

Max

MatchMaker wrote:

> Hello all you php and mysql guruz,
>
> I am trying to setup a database using the script below, however the script
> tries to create a new database on the server and I want to use an existing
> database already created.
>
> How can I use the info in this to just insert it into an existing database?
>
> Thanks,
>
> Larry;-)
>
> ----------------------------------------------------------------------------
> ------------------------------
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/REC-html40/loose.dtd">
> <html>
> <head>
> <title>Remove this file after successful creation of database and
> tables!</title>
> </head>
> <body>
> <?php
>
> $link_id = mysql_connect("localhost",$userid,$userpassword) or die ("Error
> connecting to the database server.");
> echo "Connected to the mySQL server...<br>"; // added in v1.50.03 (DV)
>
> if(!mysql_query("create database $dbname")) die("Error creating $dbname
> database"); // changed in v1.50.03 (DV)
> echo "Successfully created the $dbname database.<br>";
>
> mysql_select_db($dbname);
>
> $tablename = "paddata";
> $fields = "company varchar(50) not null,";
> $fields .= "title varchar(50) not null,";
> $fields .= "version varchar(10),";
> $fields .= "pdate date,";
> $fields .= "website varchar(128),";
> $fields .= "email varchar(50),";
> $fields .= "cost float,";
> $fields .= "ptype varchar(15),";
> $fields .= "os varchar(80),";
> $fields .= "ksize int,";
> $fields .= "category varchar(50),";
> $fields .= "keywords varchar(128),";
> $fields .= "description text,";
> $fields .= "homepage varchar(128),";
> $fields .= "screenshot varchar(128),";
> $fields .= "padfile varchar(128),";
> $fields .= "download varchar(128),";
> $fields .= "aspnumber varchar(5),";
> $fields .= "poll int default '0',";
> $fields .= "primary key (company, title)";
>
> if(!mysql_query("create table $tablename ($fields)")) die("Error creating
> $tablename table");
> echo "Successfully created $tablename table.<br>";
>
> $tablename = "editlog";
> $fields = "logtime datetime,";
> $fields .= "aspnumber varchar(5),";
> $fields .= "ipaddr varchar(15),";
> $fields .= "action varchar(100)";
>
> if(!mysql_query("create table $tablename ($fields)")) die("Error creating
> $tablename table");
> echo "Successfully created $tablename table.<br>";
>
> mysql_close($link_id);
>
> echo "<br>You can safely remove this file from your server now.<br>"; //
> added in v1.50.03 (DV)
> ?>
> </body></html>
>
>



Relevant Pages

  • Re: db repair
    ... Server. ... VB Script looks amazingly like VBA, since they're both based upon the same ... See http://www.mvps.org/access/general/gen0041.htm for the VBA code to ... this won't compact the database ...
    (microsoft.public.access.setupconfig)
  • Re: VB Script to dismount stores
    ... I have the exact script you are looking for in fact, ... I had to force my exchange hard drives back on so ... ' This code will dismount the selected mailbox database. ... I changed the server and store names but when I run the script I get ...
    (microsoft.public.exchange.admin)
  • RE: Cant call method "prepare" on an undefined value
    ... The error happen on the line to connect to that database: ... This script is working fine I located the script in same server as the ... I have one oracle database located at server A and setup the Oracle ... When I run the perl script, ...
    (perl.dbi.users)
  • Re: Get custom database properties from an Access database
    ... It doesn't matter if the VBScript process drags, since it is an independent process and so will have no effect on the user's interaction with the database. ... The user can skip merrily along, doing whatever he needs while the script invisibly figures out the current situation in the background and decides what to do about it. ... It does, but I've run into issues other places on this same network, where users needed a drive letter to a server. ...
    (microsoft.public.scripting.vbscript)
  • Re: Get custom database properties from an Access database
    ... write the script to look for an available letter, ... If you're concerned about another drive letter causing ... will have no effect on the user's interaction with the database. ... As for the server, yes, that would definitely be the way to go. ...
    (microsoft.public.scripting.vbscript)