Connecting my Mysql Database with my web server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vkas
    New Member
    • Feb 2009
    • 78

    Connecting my Mysql Database with my web server

    i have a domain www.thesunriseschool.com

    for connecting the database i am using

    Code:
    <?php
    $sId=session_id();
    $uIp=$_SERVER['REMOTE_ADDR'];
    $time=time();
    $date_now=date("d/m/Y", $time);
    $time_now=date("G:i:s", $time);
    if(isset($_SERVER['HTTP_REFERER'])){
    	$referer=$_SERVER['HTTP_REFERER'];
    }else{
    	$referer="http://www.thesunriseschool.com";
    }
    
    if($_SERVER['HTTP_HOST']=="localhost" || $_SERVER['HTTP_HOST']=="192.168.1.12"){
    	$dbhost = 'localhost';
    	$dbuser = 'root';
    	$dbpass = '';
    	$dbname = 'Sunrise';
    }else{
    	$dbhost = 'http://www.thesunriseschool.com/';
    	$dbuser = 'xxxxx';
    	$dbpass = 'xxxxx';
    	$dbname = 'thesun_Sunrise';
    }
    
    $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ($dbname);
    function dbQuery($sql){
    	$qry=mysql_query($sql);
    	return $qry;}
    ?>



    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)
    Last edited by Dormilich; Nov 14 '09, 11:16 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

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

    Comment

    • Vkas
      New Member
      • Feb 2009
      • 78

      #3
      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.pmnho st.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.pmnho st.net' (using password: NO)

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by Vkas
        (using password: NO)


        obviously you forgot to pass the password.

        Comment

        • Vkas
          New Member
          • Feb 2009
          • 78

          #5
          which password i should give for this user!!!!!!!

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

          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???

          Comment

          • Vkas
            New Member
            • Feb 2009
            • 78

            #6
            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.thesunrise school.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.pmnho st.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.pmnho st.net' (using password: YES)


            i dont know y
            Last edited by Dormilich; Nov 14 '09, 05:59 PM. Reason: don’t give away your passwords

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              did you enable remote acces for the DB (that is usually disabled)?

              Comment

              • Vkas
                New Member
                • Feb 2009
                • 78

                #8
                from where should i do that from c panel ????

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  I do not use c panel… so I don’t know

                  Comment

                  Working...