Jump to content

[SOLVED] queries using php


daled

Recommended Posts

i've got a problem (so does everybody else). anyways.  php won't execute this query for me:

 

<?php
$query = 
	sprintf("CREATE DATABASE `$dbname`
		-- 
		-- Table structure for table 'addressbook'
		-- 

		CREATE TABLE IF NOT EXISTS `addressbook` (
		  `team` varchar(255) NOT NULL default '',
		  `number` mediumint(9) NOT NULL auto_increment,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'albums'
		-- 

		CREATE TABLE IF NOT EXISTS `albums` (
		  `album` varchar(255) NOT NULL default '',
		  `number` smallint(6) NOT NULL auto_increment,
		  `description` longtext NOT NULL,
		  `thumbnail` varchar(255) NOT NULL default '',
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'basicinfo'
		-- 

		CREATE TABLE IF NOT EXISTS `basicinfo` (
		  `bandname` varchar(255) NOT NULL default '',
		  `bio` longtext NOT NULL,
		  `genre` varchar(255) NOT NULL default '',
		  `avatar` varchar(255) NOT NULL default ''
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'comments'
		-- 

		CREATE TABLE IF NOT EXISTS `comments` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `poster` varchar(255) NOT NULL default '',
		  `IP` varchar(255) NOT NULL default '',
		  `time` varchar(255) NOT NULL default '',
		  `date` varchar(255) NOT NULL default '',
		  `comment` longtext NOT NULL,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'dates'
		-- 

		CREATE TABLE IF NOT EXISTS `dates` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `date` varchar(255) NOT NULL default '',
		  `time` varchar(255) NOT NULL default '',
		  `venue` varchar(255) NOT NULL default '',
		  `city` varchar(255) NOT NULL default '',
		  `state` varchar(255) NOT NULL default '',
		  `price` varchar(255) NOT NULL default '',
		  `venuesite` mediumtext NOT NULL,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'feature'
		-- 

		CREATE TABLE IF NOT EXISTS `feature` (
		  `albumnumber` varchar(255) NOT NULL default '',
		  `album` varchar(255) default NULL,
		  `1` varchar(255) default NULL,
		  `2` varchar(255) default NULL,
		  `3` varchar(255) default NULL,
		  `4` varchar(255) default NULL,
		  `5` varchar(255) default NULL
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'inbox'
		-- 

		CREATE TABLE IF NOT EXISTS `inbox` (
		  `sender` varchar(255) NOT NULL default '',
		  `time` varchar(255) NOT NULL default '',
		  `message` varchar(255) NOT NULL default '',
		  `number` mediumint(9) NOT NULL auto_increment,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'journal'
		-- 

		CREATE TABLE IF NOT EXISTS `journal` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `title` varchar(255) NOT NULL default '',
		  `time` varchar(255) NOT NULL default '',
		  `date` varchar(255) NOT NULL default '',
		  `journal` longtext NOT NULL,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'members'
		-- 

		CREATE TABLE IF NOT EXISTS `members` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `name` varchar(255) NOT NULL default '',
		  `instrument` varchar(255) NOT NULL default '',
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'pictures'
		-- 

		CREATE TABLE IF NOT EXISTS `pictures` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `url` varchar(255) NOT NULL default '',
		  `description` longtext NOT NULL,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'requests'
		-- 

		CREATE TABLE IF NOT EXISTS `requests` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `name` varchar(255) NOT NULL default '',
		  `city` varchar(255) NOT NULL default '',
		  `state` varchar(255) NOT NULL default '',
		  `notes` longtext NOT NULL,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;


		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'sentmessages'
		-- 

		CREATE TABLE IF NOT EXISTS `sentmessages` (
		  `recipient` varchar(255) NOT NULL default '',
		  `time` varchar(255) NOT NULL default '',
		  `message` varchar(255) NOT NULL default '',
		  `number` mediumint(9) NOT NULL auto_increment,
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;

		-- --------------------------------------------------------

		-- 
		-- Table structure for table 'songs'
		-- 

		CREATE TABLE IF NOT EXISTS `songs` (
		  `number` smallint(6) NOT NULL auto_increment,
		  `song` varchar(255) NOT NULL default '',
		  `album` varchar(255) NOT NULL default '',
		  `albumnumber` varchar(255) NOT NULL default '',
		  `genre` varchar(255) NOT NULL default '',
		  `url` varchar(255) NOT NULL default '',
		  PRIMARY KEY  (number)
		) TYPE=MyISAM;");
	$db = mysql_query($query, $register);
?>

 

I don't get any errors (php or mysql), it just won't do it. i simply ignores it and continues.  what's up with that?

Link to comment
https://forums.phpfreaks.com/topic/60010-solved-queries-using-php/
Share on other sites

it did execute successfully.

I am going to assume you meant didn't.

 

Try catching the error:

 

$query="CREATE TABLE IF NOT EXISTS `addressbook` (
           `team` varchar(255) NOT NULL default '',
           `number` mediumint(9) NOT NULL auto_increment,
           PRIMARY KEY  (number)
         );

$try_query = mysql_query($query)or die(mysql_error());

 

Here is the syntax for creating a table:

http://dev.mysql.com/doc/refman/5.0/en/create-table.html

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.