Jump to content
  • Advertisement
Sign in to follow this  
sathenzar

[web] PHP/MySQL creating the setup pages

This topic is 5145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm making a forum that's transferrable to a new domain. The only problem is that I've never made a script to create a database before, I've jsut had PHPMyAdmin create the database and set the user account on it for me, then I'd create the tables and processes from PHP/MySQL code. So I guess my question would be how to create a database thorugh code adn then create a user account and set a password up. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
if the database is setup in phpmyAdmin, you can export the SQL statements from it and import them into the new database. That's the easiest way to move a forum.

Share this post


Link to post
Share on other sites
phpBB 2.2 has a excellent setup script (I think the best "setup program" in PHP). You can get a full of ideas with it.

Download its latest CVS: Clicky

And so execute it. It's going to run the setup for first.
It's located on folder: /install

[Edited by - Maquiavel on September 14, 2004 10:43:05 PM]

Share this post


Link to post
Share on other sites
well since I don't want to copy anyone's work, and since I already have phpMyAdmin, how do I export the database commands? Or do you mean the box it displays after you insert a database command saying you've successfully added a table then the SQL CODE: $sql = "CREATE TABLE...etc.";

Share this post


Link to post
Share on other sites
never mind that question, it doesn't make any sense. What I need to know is why I can make a successful connection, but then it tells me this:

success in database connection. Access denied for user: 'demon@localhost' to database 'demon_test'


That doesn't make any sense. That's an error that normally shows up when you don't have the password correct, but I havn't set a password. I cant' till the database is created.
Here's my test code:

<?php

// set your infomation.
$dbhost='localhost';
$dbusername='demon';
$dbuserpass='mypassword';
$dbname='test';

// connect to the mysql database server.
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);
echo "success in database connection.";

// create the database.
$dbname=$dbusername."_".$dbname;
if (!mysql_query("CREATE DATABASE $dbname")) die(mysql_error());
echo "success in database creation.";

?>
<html>
<head>
<title>Demon Realms Studios&reg; Setup 2004</title>
</head>


<body bgcolor="#FFFFFF">
If you're seeing this message, then everything went well.
</body>


</html>

Share this post


Link to post
Share on other sites
Quote:
Original post by sathenzar
well since I don't want to copy anyone's work, and since I already have phpMyAdmin, how do I export the database commands? Or do you mean the box it displays after you insert a database command saying you've successfully added a table then the SQL CODE: $sql = "CREATE TABLE...etc.";


I didn't mean you to copy phpBB. I said to you see it and I'll learn what you want. I have had the same wish as you: create a PHP Setup Page. And with this of PHPBB I created a full-of-features one.

OpenSource is here for this: to learn with others' code, with experienced coders, otherwise it wouldn't exist open source.

In your code what is happenning is that the user 'demon' doesn't have permission to create databases. Starts your PHP script with the MASTER user, GRANT permissions to user 'demon' and so you will can create databases with no problems.

[Edited by - Maquiavel on September 14, 2004 10:49:23 PM]

Share this post


Link to post
Share on other sites
ok, I see what you ment now. Well the link you provided tells me it doesn't exsist, and as for the username not having permissions, I changed the username to demon_SIAD, which has full permissions and I have used it many times in webpages to edit/retrive information from my databases many times. But it's still giving me this error:
success in database connection.Access denied for user: 'demon_SIAD@localhost' to database 'demon_SIAD_test'
Any idea's? Maybe you could post a different link that provides me with the open source code? Thanks in advance.

Share this post


Link to post
Share on other sites
$sql = "create database namehere;";
Then make your tables with create table and then put the data in them with INSERT INTO. Check mysql.com for the docs on using them.
I pwn at php and sql. Writing a portal system at the moment and almost done with sessions and user access. [http://216.68.134.98/portal/ test site ]


[edit added link]

Share this post


Link to post
Share on other sites
Ok, I'm lost, could someone jus tpost the code they've used to create databases? This is kindof getting on my nerves. My whole programmign has been halted by this pointless problem, which shouldn't be happining in the first place. So could someone jsut post the code off of a page or somthing they;ve done that wiull create a database? Thanks.

Share this post


Link to post
Share on other sites
Just make your database in phpmyadmin and look at the sql code it shows when it says it was succesfull. Or once again look on mysql.com. Don't feel like coding for you, brain dead, too much math(on something else).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!