I need help with this database

From: MatchMaker (abuse_at_wwwhotscripts.net)
Date: 11/29/03


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>



Relevant Pages

  • Re: DataAdapter.Update
    ... If it's successful, call ... I begin a transaction on my connection and attempt to update ... rows as one transaction to the database. ... now I rectify my second row in order to rectify ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Warning: supposed "lisp video" is an anti-lisp troll
    ... putting constraints into your database takes away from flexibility. ... but were running the very real risk of being ... produce a marketable product. ... Still, they have been successful for about 20 years, ...
    (comp.lang.lisp)
  • Re: WORD XP MAIL-MERGE - FAILS - USING ACCESS QUERY
    ... They changed the method used to connect to an Access database in Word ... > So it is somehow Word not reading the Query successfully I guess. ... > "old" successful mail-merge is that if I look at the Mail-merge ...
    (microsoft.public.word.application.errors)
  • re: Custom querys - ORDER BY clause?
    ... >simple asp page with a seach form and parameters that ... >successful but runtime viewing produces a "The operation ... Microsoft FrontPage MVP ... || Web Database Development Step by Step .NET Edition ...
    (microsoft.public.frontpage.programming)
  • Re: Connect to the mysql already?
    ... echo "The table $TableName was successfully created"; ... > * passing variables through GET when you're declaring them within your ... > # create a database if one doesn't exist ... i get all successful message. ...
    (comp.lang.php)