PDA

View Full Version : mysql help



Colin-Roberts
12-08-2008, 09:56 PM
can anyone give me a code to add a table to mysql database via php file.. my phpmyadmin won't open but mysql is still online..

Excellent1
12-08-2008, 10:07 PM
You could drop them in via php, find an installer :)

Colin-Roberts
12-08-2008, 10:16 PM
i got this

<?php
// Make a MySQL Connection
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE `messages` (
`id` int(11) NOT NULL auto_increment,
`reciever` varchar(25) NOT NULL default '',
`sender` varchar(25) NOT NULL default '',
`subject` text NOT NULL,
`message` longtext NOT NULL,
`recieved` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`)")
or die(mysql_error());

echo "Table Created!";

?>

but it gives this error:
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 '' at line 8

Excellent1
12-08-2008, 10:21 PM
Add this on the end.
) TYPE=MyISAM;

Colin-Roberts
12-08-2008, 10:26 PM
still same error.

VistaBoy
12-08-2008, 11:58 PM
Try this:



<?php
// Make a MySQL Connection
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());

// Create a MySQL table in the selected database
mysql_query("CREATE TABLE messages (
id int unsigned NOT NULL auto_increment,
reciever varchar(25) NOT NULL default '',
sender varchar(25) NOT NULL default '',
subject text NOT NULL,
message longtext NOT NULL,
recieved enum('0','1') NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM;")or die(mysql_error());

echo "Table Created!";

?>


can not say it will work but give it a go.

Colin-Roberts
13-08-2008, 12:52 AM
rep. it worked.

VistaBoy
13-08-2008, 12:57 AM
Cool its good that thats works i have not made mysql tables for about 5 weeks ;)

Colin-Roberts
13-08-2008, 12:27 PM
nvm fixed it. missed a session start..
how i get rid of all these errors:
Warning: session_start() [function.session-start (http://zetolic.com/en/function.session-start)]: Cannot send session cache limiter - headers already sent

also..
I'm using a php navigation
that does ?page=viewmsg
So how do i get viewmsg.php?msg_id=5
to work with that.

Decode
13-08-2008, 01:02 PM
nvm fixed it. missed a session start..
how i get rid of all these errors:
Warning: session_start() [function.session-start (http://zetolic.com/en/function.session-start)]: Cannot send session cache limiter - headers already sent

also..
I'm using a php navigation
that does ?page=viewmsg
So how do i get viewmsg.php?msg_id=5
to work with that.
For the session_start() error, make sure session_start() is right at the top of your code.

Mistajam
13-08-2008, 01:04 PM
nvm fixed it. missed a session start..
how i get rid of all these errors:
Warning: session_start() [function.session-start (http://zetolic.com/en/function.session-start)]: Cannot send session cache limiter - headers already sent

also..
I'm using a php navigation
that does ?page=viewmsg
So how do i get viewmsg.php?msg_id=5
to work with that.
?page=viewmsg.php&msg_id=5

Colin-Roberts
13-08-2008, 01:14 PM
ok I got it. just need to viewmsg thing

Want to hide these adverts? Register an account for free!