|
How to connect to MySql database on shared hosting
04-16-2005, 10:28 AM
|
How to connect to MySql database on shared hosting
|
Posts: 87
Location: Birmingham
|
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
|
|
|
|
04-16-2005, 01:19 PM
|
|
Posts: 3,110
Location: Toronto, Ontario
|
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.
|
|
|
|
04-16-2005, 01:21 PM
|
|
Posts: 89
Location: Manchester, UK
|
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
|
|
|
|
04-16-2005, 02:36 PM
|
|
Posts: 87
Location: Birmingham
|
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
|
|
|
|
04-16-2005, 07:58 PM
|
|
Posts: 253
Location: Constanta,Romania
|
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.
|
|
|
|
04-17-2005, 08:02 AM
|
|
Posts: 87
Location: Birmingham
|
Thanks to Chroder, dotcomguy & Raulică for your help, its appreciated.
|
|
|
|
05-16-2005, 12:55 PM
|
|
Posts: 174
Location: Nigeria/Lagos
|
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..
|
|
|
|
05-16-2005, 01:05 PM
|
|
Posts: 87
Location: Birmingham
|
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. 
|
|
|
|
05-16-2005, 01:08 PM
|
|
Posts: 174
Location: Nigeria/Lagos
|
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.
|
|
|
|
05-16-2005, 01:29 PM
|
|
Posts: 87
Location: Birmingham
|
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.
|
|
|
|
05-16-2005, 01:45 PM
|
|
Posts: 174
Location: Nigeria/Lagos
|
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.
|
|
|
|
05-16-2005, 02:10 PM
|
|
Posts: 87
Location: Birmingham
|
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. 
|
|
|
|
05-16-2005, 02:13 PM
|
|
Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
|
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 :)
.
|
|
|
|
05-16-2005, 02:15 PM
|
|
Posts: 174
Location: Nigeria/Lagos
|
There you go... you are on your way in using MyPHPAdmin... hehehehe thanks Omu.. .. i have to check those links out.. too.
|
|
|
|
05-16-2005, 02:18 PM
|
|
Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
|
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 :)
.
|
|
|
|
05-16-2005, 02:57 PM
|
|
Posts: 87
Location: Birmingham
|
Thanks very much guys, its good to know that help is here if needed. 
|
|
|
|
05-16-2005, 03:00 PM
|
|
Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
|
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 :)
.
|
|
|
|
05-16-2005, 03:01 PM
|
|
Posts: 87
Location: Birmingham
|
Thanks OmuCuSucu il check out that article too. 
|
|
|
|
05-20-2005, 03:34 PM
|
|
Posts: 87
Location: Birmingham
|
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?
|
|
|
|
|
« Reply to How to connect to MySql database on shared hosting
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|