Database - CPanel

Thread Solved

Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Database - CPanel

 
0
  #1
Jun 27th, 2009
A friend referred me to this forum knowing I've been struggling for quite a while unable to find proper help. She says the people here are excellent and quick to respond. I do hope I am posting this is the correct forum area.

My problem is is that I have a website hosted and my host allows me to use CPanel to create databases. However, I am unsure how the heck to implement these databases in my website in any sort of way. I hope that someone here knows how to use CPanel and could help me with this issue because my website would be much more fantastic if only I could use databases. Please help me out.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 27
Reputation: elamigosam is an unknown quantity at this point 
Solved Threads: 1
elamigosam elamigosam is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #2
Jun 27th, 2009
what I had to do, after a long discussion with a tech suport that hardly speak engish that I have to add the username before the databse name..
example:

mysql_select_db("username_database"

hope this helps.

PS:
look some were else before calling costumer service.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #3
Jun 27th, 2009
I know how to create the database as well as I created a user with a password for it. I've even added data to the database. I just dont know how to incorporate it into my created website.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #4
Jun 28th, 2009
Ok. Let me explain my issue a little better.

I've used CPanel to create databases, I give them a name, I apply a user to them, and in PHPMyAdmin I can create tables and add data to the tables. Now, what I need to know, is how to get my website to search these databases? How do I show this data on my website according to what link is selected, so its pulled from the database what is shown?
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 790
Reputation: pritaeas is on a distinguished road 
Solved Threads: 127
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Master Poster

Re: Database - CPanel

 
0
  #5
Jun 29th, 2009
You'll need a language to connect to them, for example PHP, Python, Ruby.

In PHP the code would look like this:

  1. $db_link = @mysql_connect('localhost', 'youruser', 'yourpass') or die(mysql_error());
  2. @mysql_select_db('yourdatabase') or die(mysql_error());
  3. $query = 'SELECT * FROM yourtable';
  4. $result = @mysql_query($query) or die(mysql_error());
  5. if ($result)
  6. {
  7. while ($row = mysql_fetch_assoc($result))
  8. {
  9. // use your data
  10. }
  11. mysql_free_result($result);
  12. }
  13. if ($db_link)
  14. mysql_close($db_link);
Last edited by pritaeas; Jun 29th, 2009 at 10:04 am.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #6
Jun 29th, 2009
Yea, I knew to use PHP, guess I should have said that. But thank you. That's a start. I don't know PHP but the best way to learn is hands on. So, I'm guessing all that connects me to the server, but then, what do I put in the "// use your data" area? Like, could you point me in the right direction of where to learn what goes there? I use w3schools to learn the web languages including PHP. However, all I seem to find on there is code that creates the database as well as insert data in it. But CPanel already does that..?
Last edited by Spunky; Jun 29th, 2009 at 5:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 27
Reputation: elamigosam is an unknown quantity at this point 
Solved Threads: 1
elamigosam elamigosam is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #7
Jun 29th, 2009
first of all you need a goal,
like me I have a site where you can add songs and lirics to it, so a user enter the site, selects its church and then sees a list of songs that his church plays, so the "//use your data" becomes title songs and authors name, and lirics.

if you have a goal already, tellus what is it that you want to do and that should help us determine what to show you.....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #8
Jun 30th, 2009
Alright then. My website is a World of Warcraft Fansite. It isn't official yet and probably wont be for a very long time. But I am ok with that, this is a learning experience.

To start out with getting a database going I'm starting with the Achievements page. In the game you can earn different achievements by accomplishing certain tasks. There are hundreds of achievements and they are listed into different categories. I.E Quests, General, Exploration, Professions. Things like that. I want it to be like where you click on a link, say, Quests, and then it lists all of the Quest achievements out that are stored in the database, and all the info that is stored with it, like how many achievement points it awards and the description of how to accomplish it. I want to be able to make it cool looking though ofcourse, not just list it in a table. But I have to start out with the basics. I'd be exstatic just to get my info to show on my page from my database.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 790
Reputation: pritaeas is on a distinguished road 
Solved Threads: 127
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Master Poster

Re: Database - CPanel

 
0
  #9
Jun 30th, 2009
This will print just one column name:

  1. while ($row = mysql_fetch_assoc($result))
  2. {
  3. // use your data
  4. echo $row['column_name'] . '<br/>';
  5. }

Play around with it first, and when you have new/more questions, post them.

In addition, it may be worthwhile to check out Smarty, to be able to separate your data from your layout. (smarty.net)
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 34
Reputation: Spunky is an unknown quantity at this point 
Solved Threads: 0
Spunky Spunky is offline Offline
Light Poster

Re: Database - CPanel

 
0
  #10
Jun 30th, 2009
Hey yea, that's actually what I tried doing with something that I found on w3schools. Except it was to show 2 column names at same time. But whatever. I couldn't get it to work. But I think I just figured it out. I put what you just told me to put in and it WORKED! OMG I love you! I have been trying to get data to show up for MONTHS! I just couldn't find the php that it took to connect to my database! Ahhhh this is a happy day.

Ok ok ok, so, how do I be hands on with my data? Like Right now it shows that one column when you go to that specific page. But, how do I stay on that same page and have a link clicked to show a different column? I'll try to figure it out myself now that I know the basics it will make it soo much easier. I want to get all the links set up first though before I try to make the data fancy.

Also another question. Is it possible to store images in a database? Can't figure it out in CPanel but it must be possible cuz I know that places that sell merchandise the images of them are stored in databases.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC