469,358 Members | 1,577 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Connecting my Mysql Database with my web server

Vkas
78
i have a domain www.thesunriseschool.com

for connecting the database i am using

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $sId=session_id();
  3. $uIp=$_SERVER['REMOTE_ADDR'];
  4. $time=time();
  5. $date_now=date("d/m/Y", $time);
  6. $time_now=date("G:i:s", $time);
  7. if(isset($_SERVER['HTTP_REFERER'])){
  8.     $referer=$_SERVER['HTTP_REFERER'];
  9. }else{
  10.     $referer="http://www.thesunriseschool.com";
  11. }
  12.  
  13. if($_SERVER['HTTP_HOST']=="localhost" || $_SERVER['HTTP_HOST']=="192.168.1.12"){
  14.     $dbhost = 'localhost';
  15.     $dbuser = 'root';
  16.     $dbpass = '';
  17.     $dbname = 'Sunrise';
  18. }else{
  19.     $dbhost = 'http://www.thesunriseschool.com/';
  20.     $dbuser = 'xxxxx';
  21.     $dbpass = 'xxxxx';
  22.     $dbname = 'thesun_Sunrise';
  23. }
  24.  
  25. $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error());
  26. mysql_select_db ($dbname);
  27. function dbQuery($sql){
  28.     $qry=mysql_query($sql);
  29.     return $qry;}
  30. ?>



i have created , a user as welll as uploaded thedatabase using the cpanel of the domain successfully but it is giving me this error

Can Any one can help me.... i think i am not writing the exact parameters


Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'http' (1) in /home/thesun/public_html/includes/config.php on line 25
I cannot connect to the database because: Unknown MySQL server host 'http' (1)
Nov 14 '09 #1

✓ answered by Dormilich

you donít connect to a DB via the HTTP protocol. just omit "http://".

8 8257
Dormilich
8,652 Expert Mod 8TB
you donít connect to a DB via the HTTP protocol. just omit "http://".
Nov 14 '09 #2
Vkas
78
ya that i done immediately......this was the 1st problemmm

thanks...
But

Now its giving this error Yet i have created following using Mysql database wizard in cpanel ........

Db= thesun_Sunrise
user=****
pass= ****



but it gives this ... error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'thesun_Vkassun'@'server.pmnhost.net' (using password: NO) in /home/thesun/public_html/includes/config.php on line 25
I cannot connect to the database because: Access denied for user 'thesun_Vkassun'@'server.pmnhost.net' (using password: NO)
Nov 14 '09 #3
Dormilich
8,652 Expert Mod 8TB
@Vkas
Ö

obviously you forgot to pass the password.
Nov 14 '09 #4
Vkas
78
which password i should give for this user!!!!!!!

i am using this configuration for my local site
$dbuser='root'
$dbpass='' (Empty)
$dbname='Sunrise'

and it works... connects to the database after this i export the database file
and save it on my hard disk...


Now for web server
i have created a data base name Sunrise Using mysqlwizard in cpanel of the site...

and user Vkasun with a password
i import my local database using phpmyadmin of cpanel it is restored successfully ... and change the configuration of my phpmysql connection but it doesnt works... y???
Nov 14 '09 #5
Vkas
78
which password should i passed


My local configuration is
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'sunrise';
phpmyadmin Having (root with password:NO)

this works perfectly at local then with the same condition i Export the database and save it top my hard drive after that

i goto the cpanel make a data base using mysqlwizard
Databasename : thesun_Sunrise
User :thesun_Vkassun
pass : xyx

and the restore the database by the phpmyadmin...in the cpanel
database is successfully store

the i change the setting of my connection to
$dbhost = 'www.thesunriseschool.com';
$dbuser = '****';
$dbpass = '****';
$dbname = 'thesun_Sunrise';.


but it gives me this error


Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'thesun_Vkassun'@'server.pmnhost.net' (using password: YES) in /home/thesun/public_html/includes/config.php on line 25
I cannot connect to the database because: Access denied for user 'thesun_Vkassun'@'server.pmnhost.net' (using password: YES)


i dont know y
Nov 14 '09 #6
Dormilich
8,652 Expert Mod 8TB
did you enable remote acces for the DB (that is usually disabled)?
Nov 14 '09 #7
Vkas
78
from where should i do that from c panel ????
Nov 16 '09 #8
Dormilich
8,652 Expert Mod 8TB
I do not use c panelÖ so I donít know
Nov 16 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by kamilla | last post: by
6 posts views Thread by MBS | last post: by
4 posts views Thread by CodeImp | last post: by
3 posts views Thread by Paradox Synthesist | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.