Jump to content

Creating a database and a table?


eduard

Recommended Posts

  • Replies 74
  • Created
  • Last Reply

there's no big secret to uploading files to your host. It's pretty simple. You make a website on your computer and the you upload it. You keep making changes locally and then upload the changes as you make them (and have verified it works to your specifications). You don't delete anything unless you know you don't need it anymore. The whole idea is to have identical copies (more or less) locally and live. Locally you can make changes, and if you screw something up, you can pull down your hosted files. (there are systems for handling just this kind of thing, but require decent competency on behalf of the user in order to implement).edit: you aren't referring to the database as the file to uploaded, are? Because you know that databases themselves aren't actually files.

Link to comment
Share on other sites

there's no big secret to uploading files to your host. It's pretty simple. You make a website on your computer and the you upload it. You keep making changes locally and then upload the changes as you make them (and have verified it works to your specifications). You don't delete anything unless you know you don't need it anymore. The whole idea is to have identical copies (more or less) locally and live. Locally you can make changes, and if you screw something up, you can pull down your hosted files. (there are systems for handling just this kind of thing, but require decent competency on behalf of the user in order to implement).
But I always have to save the file on my webserver-because that causes the problem (mysql connection!)?
Link to comment
Share on other sites

right, because that's the point of a webserver, to host files used in the deployment of websites. It's the way to run PHP files and enable database management. However, you may still be running a webserver, and running scripts and HTML pages, and also have a problem connecting with database (mysql_connect). So what you do is keep everything the way you had it, and just try and fix the connection to the mysql database. Try and get it back to the way you had it before, if possible.

Link to comment
Share on other sites

there's no big secret to uploading files to your host. It's pretty simple. You make a website on your computer and the you upload it. You keep making changes locally and then upload the changes as you make them (and have verified it works to your specifications). You don't delete anything unless you know you don't need it anymore. The whole idea is to have identical copies (more or less) locally and live. Locally you can make changes, and if you screw something up, you can pull down your hosted files. (there are systems for handling just this kind of thing, but require decent competency on behalf of the user in order to implement).edit: you aren't referring to the database as the file to uploaded, are? Because you know that databases themselves aren't actually files.
Yes, finally I know your edit, but I posted another topic to ´see´ the database?
Link to comment
Share on other sites

right, because that's the point of a webserver, to host files used in the deployment of websites. It's the way to run PHP files and enable database management. However, you may still be running a webserver, and running scripts and HTML pages, and also have a problem connecting with database (mysql_connect). So what you do is keep everything the way you had it, and just try and fix the connection to the mysql database. Try and get it back to the way you had it before, if possible.
But I have the same problem (AGAIN)!Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'eduardli'@'localhost' (using password: YES) in /home/eduardli/public_html/web_designer/crdb.php on line 2Could not connect: Access denied for user 'eduardli'@'localhost' (using password: YES)
Link to comment
Share on other sites

right, because that's the point of a webserver, to host files used in the deployment of websites. It's the way to run PHP files and enable database management. However, you may still be running a webserver, and running scripts and HTML pages, and also have a problem connecting with database (mysql_connect). So what you do is keep everything the way you had it, and just try and fix the connection to the mysql database. Try and get it back to the way you had it before, if possible.
That´s what I´ve been trying the past 6 days!
Link to comment
Share on other sites

You're right, this is exactly the same problem: the MySQL username and password you're using to connect are not correct. New code isn't going to solve that problem, you need to get the correct user name and password. If your hosted server has a control panel that you can log in to in order to do things like set up email addresses, create databases, connect to phpMyAdmin, etc, then you may be able to create a new MySQL user in there and give them permission to access your database.So, this is what you need to do:1. First, try the same username and password that you use with your FTP client when you upload files. Put those in the PHP code where you connect to the database.2. If that doesn't work, and you know where your server's control panel is, log in to it and look for things about setting up databases. You don't want to use phpMyAdmin yet, there should be another tool in the control panel to create database users.3. If you don't know where your server's control panel is, try these and use your FTP username and password to log in:http://www.yourdomain.com:2082https://www.yourdomain.com:2083Those are the standard ways to connect to cPanel, if your server is using cPanel as the control panel.4. If those don't work and you can't find your control panel, look through the emails you have received from your host, or check their website for information about how to access your site's control panel.5. If you can't find any information, contact your host and tell them how to find out what the username and password for your database are, or ask them how to get to the control panel where you can set that up yourself.

Link to comment
Share on other sites

You're right, this is exactly the same problem: the MySQL username and password you're using to connect are not correct. New code isn't going to solve that problem, you need to get the correct user name and password. If your hosted server has a control panel that you can log in to in order to do things like set up email addresses, create databases, connect to phpMyAdmin, etc, then you may be able to create a new MySQL user in there and give them permission to access your database.So, this is what you need to do:1. First, try the same username and password that you use with your FTP client when you upload files. Put those in the PHP code where you connect to the database.2. If that doesn't work, and you know where your server's control panel is, log in to it and look for things about setting up databases. You don't want to use phpMyAdmin yet, there should be another tool in the control panel to create database users.3. If you don't know where your server's control panel is, try these and use your FTP username and password to log in:http://www.yourdomain.com:2082https://www.yourdomain.com:2083Those are the standard ways to connect to cPanel, if your server is using cPanel as the control panel.4. If those don't work and you can't find your control panel, look through the emails you have received from your host, or check their website for information about how to access your site's control panel.5. If you can't find any information, contact your host and tell them how to find out what the username and password for your database are, or ask them how to get to the control panel where you can set that up yourself.
Veru interesting! It indeed has a control panel! But what is exactly a new MySQL user? 1 I´ve tried! I know where my cpanel is and I can log in it!
Link to comment
Share on other sites

OK. Hosts can configure cPanel however they want, they can turn features that you can use on and off. So, since we have that demo site take a look and see if this is specifically what you're using:http://cpanel.demo.cpanel.net/login/?user=...mp;pass=x3demob
Yes
Link to comment
Share on other sites

I'm not sure if your server is in a different language, but in the demo there, if you scroll down you'll see a section called "Databases". That section has "MySQL Databases", "MySQL Database Wizard", "phpMyAdmin", and "Remote MySQL". Your server might have all 4 of those, or it might have less. You can actually use the demo though, you can go through everything I'm about to tell you on the demo and then do the same thing on your server if you want to.If you have the "MySQL Database Wizard", it's probably easiest to start there. If you click on that link in the demo, you'll see that the first step is to create a new database. It gives you a prompt for a new database, and in the demo it starts the name with "x3demob_". That is the account name. Your database name and MySQL username will start with your account name. Your account name is probably something like "eduardli", so if you type in a database name of "test", when you go to PHP you'll call the database "eduardli_test". The same thing with users, if you make a user called "user", your user name in PHP will be "eduardli_user". So, step 1 is to create a database so you can name it whatever you want. You can call it "site", for example, and then access it as "eduardli_site". Alphanumeric means the name can only be letters and numbers, no other characters. So, type your database name in and press the Next Step button. Step 2 is to create a user and password. The user is the same thing, if you type "testuser" as the username then in PHP you use "eduardli_testuser". So type in a user name and then enter a password. There's a password generator you can use to create a random password, but if you use that make sure you copy and paste it into your PHP file before you save it because you won't be able to get it again. If you type in your own password then just use the same thing in PHP. So enter your username and password in step 2, and press the Create User button. Next, you'll pick privileges for the user. The privileges determine if the user can use things like "CREATE DATABASE", "INSERT", "DELETE", etc. Check the "All Privileges" box and it should set up the user and password for you. What you just set up is the username and password which you need to enter in PHP.If you don't have the "MySQL Database Wizard", but you have the "MySQL Databases" icon, click on that instead. You can do the same things on this page that I described above, you just do them individually. There is a form on top to create a new database, a form to modify databases, a list of the current databases, and a section to add a user to a database. If you need to, you can use those forms to create the database and user, and then use the bottom form to assign the user to the database and give them privileges.Once you have the user and database set up, you should be able to connect to the database with PHP. You can use this to test if you fill in the username and password you set up:

<?php$server = 'localhost';$user = 'eduardli_your_user_here';   // fill in your username$password = 'your password';		 // fill in your passwordmysql_connect($server, $user, $password) or exit(mysql_error());echo 'connected';?>

Fill in your details, upload that file to your server where you set this up, and open it in a browser to see if it works.

Link to comment
Share on other sites

I'm not sure if your server is in a different language, but in the demo there, if you scroll down you'll see a section called "Databases". That section has "MySQL Databases", "MySQL Database Wizard", "phpMyAdmin", and "Remote MySQL". Your server might have all 4 of those, or it might have less. You can actually use the demo though, you can go through everything I'm about to tell you on the demo and then do the same thing on your server if you want to.If you have the "MySQL Database Wizard", it's probably easiest to start there. If you click on that link in the demo, you'll see that the first step is to create a new database. It gives you a prompt for a new database, and in the demo it starts the name with "x3demob_". That is the account name. Your database name and MySQL username will start with your account name. Your account name is probably something like "eduardli", so if you type in a database name of "test", when you go to PHP you'll call the database "eduardli_test". The same thing with users, if you make a user called "user", your user name in PHP will be "eduardli_user". So, step 1 is to create a database so you can name it whatever you want. You can call it "site", for example, and then access it as "eduardli_site". Alphanumeric means the name can only be letters and numbers, no other characters. So, type your database name in and press the Next Step button. Step 2 is to create a user and password. The user is the same thing, if you type "testuser" as the username then in PHP you use "eduardli_testuser". So type in a user name and then enter a password. There's a password generator you can use to create a random password, but if you use that make sure you copy and paste it into your PHP file before you save it because you won't be able to get it again. If you type in your own password then just use the same thing in PHP. So enter your username and password in step 2, and press the Create User button. Next, you'll pick privileges for the user. The privileges determine if the user can use things like "CREATE DATABASE", "INSERT", "DELETE", etc. Check the "All Privileges" box and it should set up the user and password for you. What you just set up is the username and password which you need to enter in PHP.If you don't have the "MySQL Database Wizard", but you have the "MySQL Databases" icon, click on that instead. You can do the same things on this page that I described above, you just do them individually. There is a form on top to create a new database, a form to modify databases, a list of the current databases, and a section to add a user to a database. If you need to, you can use those forms to create the database and user, and then use the bottom form to assign the user to the database and give them privileges.Once you have the user and database set up, you should be able to connect to the database with PHP. You can use this to test if you fill in the username and password you set up:
<?php$server = 'localhost';$user = 'eduardli_your_user_here';   // fill in your username$password = 'your password';		 // fill in your passwordmysql_connect($server, $user, $password) or exit(mysql_error());echo 'connected';?>

Fill in your details, upload that file to your server where you set this up, and open it in a browser to see if it works.

I can set my cpanel in english! I know where I can set a database! I have a database wizard! Now I´m going to do the steps you wrote and after I´ll check if I have connection to it!
Link to comment
Share on other sites

Most people add tables using phpMyAdmin. There should be a link inside cPanel to phpMyAdmin, and you can use that to set up the tables in the database you created in the wizard.
I know that! But that´s my other post (I can´t log in- tried many times!)
Link to comment
Share on other sites

You can't log in to phpMyAdmin on your hosted server through cPanel? You should be able to use the same username/password you log in to cPanel with.
Unfortunately, it doesn´t work! (error 1045)
Link to comment
Share on other sites

Try using the MySQL username and password you created in the wizard to log in to phpMyAdmin, those might work also.If that doesn't work, you can just create a script to set up the tables and run it once. All it needs is the code to connect, select the database, and then queries to create the tables. You can post your code for that if you need help with it.

Link to comment
Share on other sites

No, it's probably simplest to just make a new file only to set up the database. You only need to run it once.
So I have to combine the files create a db and create a table?
Link to comment
Share on other sites

You've already created the database using the wizard, all you need to do is use mysql_connect to connect to the server, use mysql_select_db to select the database you created, and then start running CREATE TABLE queries to set up the tables you want in that database.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...