+ Reply to Thread
Results 1 to 8 of 8

Thread: X10 hosting help mysql

  1. #1
    Xtendcorp is offline x10Hosting Member Xtendcorp is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    united kingdom
    Posts
    3

    Exclamation X10 hosting help mysql

    I am making a php/mysql based login system and im trying to find how to conect with a database

    in the script it says:

    Code:
    <?php
      $host="localhost"; // Host name 
      $username=""; // Mysql username 
      $password=""; // Mysql password 
      $db_name="test"; // Database name 
      $tbl_name="members"; // Table name 
                                                           // Connect to server and select databse.
      mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
      mysql_select_db("$db_name")or die("cannot select DB");
                                                           // username and password sent from  form 
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
                                                           // To protect MySQL injection (more detail about MySQL injection)
                                                            $myusername = stripslashes($myusername);
                                                            $mypassword = stripslashes($mypassword);
                                                            $myusername = mysql_real_escape_string($myusername);
                                                          $mypassword = mysql_real_escape_string($mypassword);
                                                           $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
                                                            $result=mysql_query($sql);
                                                           // Mysql_num_row is counting table row
                                                            $count=mysql_num_rows($result);
                                                            // If result matched  $myusername  and $mypassword,  table row must be 1 row
                                                           if($count==1){
                                                            // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword"); 
                                          header("location:login_success.php");
                                          }
                                          else {
                                          echo "Wrong Username or Password";
                                          }
                                          ?>

    So basicaly cut it down to this:

    Code:
    $host="localhost"; // Host name 
      $username=""; // Mysql username 
      $password=""; // Mysql password 
      $db_name="test"; // Database name 
      $tbl_name="members"; // Table name                                                          // Connect to server and select databse.
    the database user,pass and db name is fine but how would i connect tio the db host?

    please help me quick!

  2. #2
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: X10 hosting help mysql

    the username is *cpanelusername*_*databaseusername*. Password is your cPanel password. db name is *cpanelname*_*dbname*.

  3. #3
    Xtendcorp is offline x10Hosting Member Xtendcorp is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    united kingdom
    Posts
    3

    Re: X10 hosting help mysql

    Could i please have a wucim example with random username and password??
    i get it but nit the last bit the :

    db name is *cpanelname*_*dbname*.
    thanks"!

  4. #4
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: X10 hosting help mysql

    You need to create a database in cPanel. So if your cPanel name is hello, and the database name is user, it would become hello_user

  5. #5
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: X10 hosting help mysql

    for php

    PHP Code:
    <?php
    mysql_connect
    ("localhost""yourusername""yourpassword") or die(mysql_error());
    echo 
    "Connected to MySQL<br />";
    ?>
    Last edited by vol7ron; 12-13-2008 at 09:31 AM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  6. #6
    Xtendcorp is offline x10Hosting Member Xtendcorp is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    united kingdom
    Posts
    3

    Re: X10 hosting help mysql

    Thanks so much that will really help me ,
    I will be asking more porbably later
    thanks!

  7. #7
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: X10 hosting help mysql

    np don't forgive to give people rep if they helped ya
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  8. #8
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: X10 hosting help mysql

    haha that was forget* not forgive. either way, i'm here to help when i can, that way people can help me when i have problems.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


+ Reply to Thread

Similar Threads

  1. How to create MySQL database and user
    By Jesse in forum Tutorials
    Replies: 11
    Last Post: 06-04-2008, 12:25 PM
  2. MySQL Issues Here
    By Corey in forum Service Alerts
    Replies: 304
    Last Post: 01-06-2008, 09:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers