| | |
query problem (delimiter?)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I have a program which requires a database. So I made a file that could generate the sql to create it (I copied the sql from PHPmyadmin as reference). When I execute the sql I get the error: It's always on the first ; that the error occurs. If I execute it in PHPmyadmin it works and correctly creates the database. I think the problem lays with the 'delimiter'. I tried googling it but I didn't found anything to solve my problem. This is the sql my file generate“s: Any help would be highly appreciated. Edit: The layout seems messed up, I don't get what's wrong. Sorry about it. It doesn't seems to recognize enters anymore.
PHP Syntax (Toggle Plain Text)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; USE `anonymusiusform`; -- ------------------------------------------------' at line 4
PHP Syntax (Toggle Plain Text)
-- -- Database: `anonymusiusform` -- CREATE DATABASE `anonymusiusform` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `anonymusiusform`; -- -------------------------------------------------------- -- -- Table structure for table `enquete` -- CREATE TABLE IF NOT EXISTS `enquete` ( `id` int(5) NOT NULL auto_increment, `ip` varchar(16) NOT NULL, `host` varchar(50) NOT NULL, `age` varchar(2) NOT NULL, `name` varchar(50) NOT NULL, `rank` varchar(8) NOT NULL, `opmerking` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Last edited by Anonymusius; May 3rd, 2007 at 9:30 am.
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Solved Threads: 0
Hmmm.. how about removing the superfluous comment detritus ... try:
CREATE DATABASE `anonymusiusform`
DEFAULT CHARACTER SET latin1
COLLATE latin1_swedish_ci;
USE `anonymusiusform`;
CREATE TABLE IF NOT EXISTS `enquete` (
`id` int(5) NOT NULL auto_increment,
`ip` varchar(16) NOT NULL,
`host` varchar(50) NOT NULL,
`age` varchar(2) NOT NULL,
`name` varchar(50) NOT NULL,
`rank` varchar(8) NOT NULL,
`opmerking` text NOT NULL,
PRIMARY KEY (`id`) )
ENGINE=InnoDB
DEFAULT CHARSET=latin1
AUTO_INCREMENT=1 ;
CREATE DATABASE `anonymusiusform`
DEFAULT CHARACTER SET latin1
COLLATE latin1_swedish_ci;
USE `anonymusiusform`;
CREATE TABLE IF NOT EXISTS `enquete` (
`id` int(5) NOT NULL auto_increment,
`ip` varchar(16) NOT NULL,
`host` varchar(50) NOT NULL,
`age` varchar(2) NOT NULL,
`name` varchar(50) NOT NULL,
`rank` varchar(8) NOT NULL,
`opmerking` text NOT NULL,
PRIMARY KEY (`id`) )
ENGINE=InnoDB
DEFAULT CHARSET=latin1
AUTO_INCREMENT=1 ;
I removed the comments (they were just for fun there, and with enters it actually looked more structured) and it didn't seem to work, still the same error. I google'd a few times and searched through the mysql documentation but I didn't found anything that solve's this. Any help is highly appreciated. Here is the query again, and this time better formatted
:
I traced the enter problem down to me not enabling javascript because the site is dogslow (for me) with javascript enabled. So again sorry for my previous post.
: PHP Syntax (Toggle Plain Text)
-- -- Database: `anonymusiusform` -- CREATE DATABASE `anonymusiusform` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `anonymusiusform`; -- -------------------------------------------------------- -- -- Table structure for table `enquete` -- CREATE TABLE IF NOT EXISTS `enquete` ( `id` int(5) NOT NULL auto_increment, `ip` varchar(16) NOT NULL, `host` varchar(50) NOT NULL, `age` varchar(2) NOT NULL, `name` varchar(50) NOT NULL, `rank` varchar(8) NOT NULL, `opmerking` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I made it work, my solution is however not so pretty looking:
[php]$query = '--
-- Database: `anonymusiusform`
--
CREATE DATABASE `anonymusiusform` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `anonymusiusform`;
-- --------------------------------------------------------
--
-- Table structure for table `enquete`
--
CREATE TABLE IF NOT EXISTS `enquete` (
`id` int(5) NOT NULL auto_increment,
`ip` varchar(16) NOT NULL,
`host` varchar(50) NOT NULL,
`age` varchar(2) NOT NULL,
`name` varchar(50) NOT NULL,
`rank` varchar(8) NOT NULL,
`opmerking` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;';
mysql_connect('localhost', 'username', 'password');
foreach(explode(';', $query) as $value)
{
if($value == ''){continue;}
mysql_query($value) or die(mysql_error());
}[/php]
It works now, I only use the application and it is only in the adminscreen so I will always be able to dump sql in case of a crash in phpmyadmin. If someone has a better solution please tell me.
[php]$query = '--
-- Database: `anonymusiusform`
--
CREATE DATABASE `anonymusiusform` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `anonymusiusform`;
-- --------------------------------------------------------
--
-- Table structure for table `enquete`
--
CREATE TABLE IF NOT EXISTS `enquete` (
`id` int(5) NOT NULL auto_increment,
`ip` varchar(16) NOT NULL,
`host` varchar(50) NOT NULL,
`age` varchar(2) NOT NULL,
`name` varchar(50) NOT NULL,
`rank` varchar(8) NOT NULL,
`opmerking` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;';
mysql_connect('localhost', 'username', 'password');
foreach(explode(';', $query) as $value)
{
if($value == ''){continue;}
mysql_query($value) or die(mysql_error());
}[/php]
It works now, I only use the application and it is only in the adminscreen so I will always be able to dump sql in case of a crash in phpmyadmin. If someone has a better solution please tell me.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- MySql multiple table query problem.... (MySQL)
- query problem (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Contact us form help
- Next Thread: help with forms
| Thread Tools | Search this Thread |
.htaccess apache api array autocomplete beginner binary body broken cakephp class cms code convert cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu methods multiple mycodeisbad mysql network number object oop paypal pdf php phpincludeissue query random recursive redirect remote script search securephp server sessions shot source sp space speed sql subdomain subscription system table tag tutorial tutorials upload url validator variable vbulletin video web white youtube





