I need help with this database
From: MatchMaker (abuse_at_wwwhotscripts.net)
Date: 11/29/03
- Next message: Five Cats: "Re: I need help with this database"
- Previous message: RonS: "Re: Free php host?"
- Next in thread: Five Cats: "Re: I need help with this database"
- Reply: Five Cats: "Re: I need help with this database"
- Reply: Max Nokhrin: "Re: I need help with this database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Nov 2003 16:03:10 -0500
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: Five Cats: "Re: I need help with this database"
- Previous message: RonS: "Re: Free php host?"
- Next in thread: Five Cats: "Re: I need help with this database"
- Reply: Five Cats: "Re: I need help with this database"
- Reply: Max Nokhrin: "Re: I need help with this database"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|