Probleem met tabellen in te voegen
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
mysql_connect("192.168.1.235","username","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql = "<insert_sql_here>";
$query = mysql_query($sql) or die(mysql_error());
echo("Query successfully executed");
?>
mysql_connect("192.168.1.235","username","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql = "<insert_sql_here>";
$query = mysql_query($sql) or die(mysql_error());
echo("Query successfully executed");
?>
dus:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
mysql_connect("192.168.1.235","username","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql = "<CREATE TABLE `jump_deejays` (
`id` int(6) NOT NULL auto_increment,
`djname` varchar(150) NOT NULL default '',
`name` varchar(150) NOT NULL default '',
`residence` varchar(150) NOT NULL default '',
`age` int(2) NOT NULL default '0',
`musicstyle` varchar(250) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`website` varchar(250) NOT NULL default '',
`extra_info` text NOT NULL,
`picture` varchar(25) NOT NULL default '',
`picture_width` int(3) NOT NULL default '0',
`picture_height` int(3) NOT NULL default '0',
`datum_toegevoegd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_toegevoegd` varchar(15) NOT NULL default '',
`datum_gewijzigd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_gewijzigd` varchar(15) NOT NULL default '',
`status` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
CREATE TABLE `jump_deejays_comments` (
`id` int(6) NOT NULL auto_increment,
`dj_id` int(6) NOT NULL default '0',
`name` varchar(100) NOT NULL default '',
`comment` text NOT NULL,
`datum_toegevoegd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_toegevoegd` varchar(15) NOT NULL default '',
`datum_gewijzigd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_gewijzigd` varchar(15) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
>";
$query = mysql_query($sql) or die(mysql_error());
echo("Query successfully executed");
?>
mysql_connect("192.168.1.235","username","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql = "<CREATE TABLE `jump_deejays` (
`id` int(6) NOT NULL auto_increment,
`djname` varchar(150) NOT NULL default '',
`name` varchar(150) NOT NULL default '',
`residence` varchar(150) NOT NULL default '',
`age` int(2) NOT NULL default '0',
`musicstyle` varchar(250) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`website` varchar(250) NOT NULL default '',
`extra_info` text NOT NULL,
`picture` varchar(25) NOT NULL default '',
`picture_width` int(3) NOT NULL default '0',
`picture_height` int(3) NOT NULL default '0',
`datum_toegevoegd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_toegevoegd` varchar(15) NOT NULL default '',
`datum_gewijzigd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_gewijzigd` varchar(15) NOT NULL default '',
`status` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
CREATE TABLE `jump_deejays_comments` (
`id` int(6) NOT NULL auto_increment,
`dj_id` int(6) NOT NULL default '0',
`name` varchar(100) NOT NULL default '',
`comment` text NOT NULL,
`datum_toegevoegd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_toegevoegd` varchar(15) NOT NULL default '',
`datum_gewijzigd` datetime NOT NULL default '0000-00-00 00:00:00',
`ip_gewijzigd` varchar(15) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
>";
$query = mysql_query($sql) or die(mysql_error());
echo("Query successfully executed");
?>
En Krijg je foutmeldingen? Krijg je überhaupt iets te zien?
Ik zou die twee CREATE apart proberen.
SanThe schreef op 27.11.2007 19:18:
Dat zal wel moeten, mysql_query() accepteert slechts 1 query per keer.Ik zou die twee CREATE apart proberen.
Daarnaast is het aan te raden om innoDB te gaan gebruiken, MyISAM is echt 10x niks, het kan zelfs geen foreignkey aanmaken. En zonder foreignkey is er geen sprake van een relationele database, dan wordt het een echte dataramp.
Bedankt