Re: I need help with this database
From: Max Nokhrin (mno11_at_lycos.com)
Date: 11/30/03
- Next message: Arjan: "mail() Bcc?"
- Previous message: Janwillem Borleffs: "Re: Emailnotificatie (sorry, this message is in dutch)"
- In reply to: MatchMaker: "I need help with this database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
>
>
- Next message: Arjan: "mail() Bcc?"
- Previous message: Janwillem Borleffs: "Re: Emailnotificatie (sorry, this message is in dutch)"
- In reply to: MatchMaker: "I need help with this database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|