Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to connect to MySql database on shared hosting
Old 04-16-2005, 10:28 AM How to connect to MySql database on shared hosting
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
I want to link my site to a MySql database on a shared hosting account, i have a MySqldump file that ive dropped into the database and realise now that i have to make a connection between my site and the database, can anyone advise my how to do this please?
I Understand it should look something like the following but of course the database is not on my own server, so what should i put in place of "localhost"
also where on the webpage should i place this text? and on all pages or just one page in particular?

<?php
$dbServer="localhost";
$dbuserName="username";
$dbpassword="password";
$dbName="table_name";
$con=mysql_connect ($dbServer, $dbuserName, $dbpassword) or die ('Cannot connect to the database.');
$db=mysql_select_db ($dbName);
?>

Any advice is appreciated
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
 
Register now for full access!
Old 04-16-2005, 01:19 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
The server will be whatever server your database is on. For example, it might be "myhost.com" or an IP address. I'm pretty sure most shared hosts don't allow mysql connections coming from outside, so you better ask.

Quote:
also where on the webpage should i place this text? and on all pages or just one page in particular?
Whenever you need to work with the database, you need to include that code. You always need a connection if you are going to be using the database.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 04-16-2005, 01:21 PM
dotcomguy's Avatar
Skilled Talker

Posts: 89
Location: Manchester, UK
Trades: 0
You can ask your webhost for the URL path to the db,

I had a similar task and I used mysql.streamline.net to access it remotely from an alternative server.

In regards to the second question make a file called conn.php and insert the relevent db info then use an include on the relevent pages.

the code would be

<?

include("conn.php");

?>
__________________

Please login or register to view this content. Registration is FREE
from just $1.85 per post.

Last edited by dotcomguy; 04-16-2005 at 01:22 PM.. Reason: wrong example
dotcomguy is offline
Reply With Quote
View Public Profile Visit dotcomguy's homepage!
 
Old 04-16-2005, 02:36 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
The MySql database is on the same account as my host package, thier not from seperate companies, i just basically wanna make a connection between my web pages and the MySql database that they provided.

Im trying to put together a URL using GET variables so that when a customer clicks, the billing popup should appear, im still unsure of where to place the code to connect to the database, is it just placed anywhere on each page or before anything in particular?

Last edited by Audioz; 04-16-2005 at 02:55 PM.. Reason: Adding more text
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 04-16-2005, 07:58 PM
Raulică's Avatar
Ultra Talker

Posts: 253
Location: Constanta,Romania
Trades: 0
It doesn`t really matter where you insert your code wich connects to the database,it matters where you insert the code wich will print the html code so it can fit on your website layout.
__________________

Please login or register to view this content. Registration is FREE

Professional hosting for all pockets!

Please login or register to view this content. Registration is FREE
Raulică is offline
Reply With Quote
View Public Profile Visit Raulică's homepage!
 
Old 04-17-2005, 08:02 AM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Thanks to Chroder, dotcomguy & Raulică for your help, its appreciated.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-16-2005, 12:55 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
i agreed with dotcomguy the easiest way u can do that is by using INCLUDE syntax..
<? php
("conn.php ");
?> i used that for one of my site and work pretty fine though i do create my Mysql database on the server using PhpMyadmin.. but really i can't figure out dumping that into d server really **** me off. instead i use phpMyadmin and that works fine 4 me..
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 01:05 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Thanks for your feedback on this Uche, i really need to try and get PhpMyadmin installed on my host account as most people recommend it. thanks for your help.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-16-2005, 01:08 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Audioz. it as already been installled by your Host Admistrator... just go into your panel and Click on MySQL Database and scrolldown to the bottom and u will find MyPHPAdmin Link and there u go.. u click on it.
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 01:29 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Unfortunately i dont have it on my account, im with fortunecity and i contacted them about it not too long ago, and they told me i would have to install phpmyadmin myself if i want it.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-16-2005, 01:45 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Ummmmmmmm thats too bad u should have scroll and see wat they offer in their Web-hosting features before buying 4rm them.. go to google and search 4.. : FREE MYPHPADMIN DWONLOAD well i haven't downloaded that before.. can't really figure out it works.. cos my host has that already.
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 01:58 PM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
phpMyAdmin download: http://www.phpmyadmin.net/home_page/downloads.php
phpMyAdmin documentation: http://www.phpmyadmin.net/home_page/docs.php

it's quiet easy to install and configure. and the download is free.
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 02:10 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Yeah your right Uche, i did do quite a lot of looking around before signing up for my package and in general im happy with the features that i have, i just didnt realise that i would need phpmyadmin, it probably sounds a bit daft, but im still learning as i go along.

Thanks OmuCuSucu, im going to check this out, ive downloaded it a few times and got confused about how to install it, and especially which folder i should be installing it to(please advise if you know more) but i definatly need to challenge this, as from what many people are saying, it seems it would make things a little easier once its installed on my host.

Thanks guys, this is helpful.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-16-2005, 02:13 PM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
you can install it anywhere as long as you configure the path right.
read the documentation carefully and if you have any trouble ask and someone will most definitely be able to help you further.

that's why WT is heaven
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 02:15 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
There you go... you are on your way in using MyPHPAdmin... hehehehe thanks Omu.. .. i have to check those links out.. too.
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-16-2005, 02:18 PM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
AudioZ, read this article: http://www.washington.edu/computing/...hpmyadmin.html

Uche: it's phpMyAdmin, not MyPHPAdmin
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 02:57 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Thanks very much guys, its good to know that help is here if needed.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-16-2005, 03:00 PM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
AudioZ help is always here when needed ... all you need is a good voice to shout out

let me know is you succeed please
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-16-2005, 03:01 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Thanks OmuCuSucu il check out that article too.
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Old 05-20-2005, 03:34 PM
Audioz's Avatar
Skilled Talker

Posts: 87
Location: Birmingham
Trades: 0
Im not sure if ive done everything correctly with the "config.inc" but once phpmyadmin is uploaded to the server, how do i actually access phpmyadmin to then use it?
Audioz is offline
Reply With Quote
View Public Profile Visit Audioz's homepage!
 
Reply     « Reply to How to connect to MySql database on shared hosting

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62404 seconds with 12 queries