PDA

View Full Version : mySQL problem(s) <--> help please



[Oli]
12-11-2006, 11:21 AM
ok so i cant access my databases in cpanel (host problems)

i can add new databases; but it doesnt show them on myphpadmin
So i have to edit etc via .php files.

How can i add a table in my database with php ?

i know how to insert into a table but i dont know how to create table with php


+rep for helpers

Thanks in advance.

YouFail
12-11-2006, 11:25 AM
Tut, Tut, Tut.

Oli it should be in Coding! :P

Anyway that should help.

[Oli]
12-11-2006, 11:40 AM
Tut, Tut, Tut.

Oli it should be in Coding! :P

Anyway that should help.

Ah yeah, sorry, always forget there's a coding section

xRoyal15
12-11-2006, 11:51 AM
Create a file... with extension .php and do the following



<?
include("config.php"); //Includes the file to connect to the database
$table = mysql_query("CREATE TABLE `tablename` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`ROWNAME` VARCHAR(LENGTH) NOT NULL,
`ROWNAME` VARCHAR(LENGTH) NOT NULL,
`ROWNAME` VARCHAR(LENGTH) NOT NULL,
`ROWNAME` VARCHAR(LENGTH) NOT NULL
) ENGINE = myisam;") or die ('Error during the execution of the MySQL query : ' . mysql_error()); //Creates the table or echos an error
echo("Done. Please delete this file... or remove it from the server");
?>


Replace `tablename` with the name of the table make sure you have `` wrapped around it.

Replace ROWNAME with the name of the row, again make sure you have ``

Replace LENGTH with the max input of the field.

If you want to make more than one table, simple edit the file with the details, and run it again.

Should all work :)

[Oli]
12-11-2006, 11:55 AM
Ah sorry didnt see your post.

I've already fixed it :)
But i will +rep you for your effort.

Thanks


Problem solved, thread can be closed or removed

xRoyal15
12-11-2006, 11:57 AM
Oki, Thanks

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