[PHP / MySQL] GuidTech, making SQL File.

Results 1 to 4 of 4
  1. #1
    Grand Master Rickpwns is offline
    Grand MasterRank
    Jun 2008 Join Date
    760Posts

    information [PHP / MySQL] GuidTech, making SQL File.

    Hey,

    I got my friends GuidTech,
    But no SQL File,
    Can anyone help me?
    The Query that will run is:
    PHP Code:
    session_start();
    $_SESSION['code'] = md5(rand(1,1000));
    $_SESSION['user'] = $user2;
    $_SESSION['nickname'] = $nickname;
    $res mysql_query("SELECT * FROM GUIDTech WHERE user='"$_SESSION['user'] ."'")or die(mysql_error());
    //$data = mysql_fetch_assoc($res);
    if(mysql_num_rows($res) >= 1) {
        
    mysql_query("UPDATE GUIDTech SET code='" $_SESSION['code'] ."', user='"$_SESSION['user'] . "', nickname='"$_SESSION['nickname']."' WHERE user='" $_SESSION['user'] ."'")or die(mysql_error());
        }
    else {
        
    mysql_query("INSERT INTO GUIDTech (user, nickname, code) VALUES ('"$_SESSION['user'] ."', '"$_SESSION['nickname']."', '" .$_SESSION['code'] ."')")or die(mysql_error());
        }
    header("Location: settings.php");
    ob_end_flush();
    ?> 
    Hope someone can create that Query for me,
    Would be very nice, will gain a thanks, and maybe something more,
    Just tell me :D

    Thanks

    *~Rickpwns~*

    P.S
    If you need any more info,
    Please reply, I really need this SQL


  2. #2
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,097Posts

    Re: [PHP / MySQL] GuidTech, making SQL File.

    What do you mean "SQL File"

    Do you mean the database for the script, or do you need MySQL installed altogether?

    What "Query" do you need created? Your terms are either wrong, or a bit of information is missing. Do you get any errors with the script? Do you have a database for this, and need to connect? Whoever gave that to you should be the one you ask for help. Make sure there isn't an installation file you forgot to run.

  3. #3
    Ginger by design. jMerliN is offline
    Grand MasterRank
    Feb 2007 Join Date
    2,500Posts

    Re: [PHP / MySQL] GuidTech, making SQL File.

    Do it for me plox.

    Rtfm.

  4. #4
    ex visor Aaron is offline
    Grand MasterRank
    May 2007 Join Date
    MichiganLocation
    4,022Posts

    Re: [PHP / MySQL] GuidTech, making SQL File.

    Wait what? I think I've gotten the idea of what you need. Basically you need the database, but first you need to connect to the database... So I think I've done this right if not someone can correct me.

    First of all to connect to the database you're going to need two files, database.php and config.php

    Database.php:
    PHP Code:
    <?PHP

    require_once ( 'config.php' );

    $MYSQL_HANDLE mysql_connect$config['db_host'], $config['db_user'], $config['db_pass'] );
    mysql_select_db$config['db_name'] ); 

    ?>
    Now you need Config.php:

    PHP Code:
    <?PHP

    $config 
    = array();
    $config['db_host'] = 'localhost';
    $config['db_user'] = 'YOUR_DATABASE_USERNAME';
    $config['db_pass'] = 'YOUR_DATABASE_PASSWORD';
    $config['db_name'] = 'YOUR_DATABASE_NAME';
    ?>
    Now your index code:

    PHP Code:
    <?PHP
    require_once('db.php');
    session_start();
    $_SESSION['code'] = md5(rand(1,1000));
    $_SESSION['user'] = $user2;
    $_SESSION['nickname'] = $nickname;
    $res mysql_query("SELECT * FROM guidtech WHERE user='"$_SESSION['user'] ."'")or die(mysql_error());
    //$data = mysql_fetch_assoc($res);
    if(mysql_num_rows($res) >= 1) {
        
    mysql_query("UPDATE guidtech SET code='" $_SESSION['code'] ."', user='"$_SESSION['user'] . "', nickname='"$_SESSION['nickname']."' WHERE user='" $_SESSION['user'] ."'")or die(mysql_error());
        }
    else {
        
    mysql_query("INSERT INTO guidtech (user, nickname, code) VALUES ('"$_SESSION['user'] ."', '"$_SESSION['nickname']."', '" .$_SESSION['code'] ."')")or die(mysql_error());
        }
    header("Location: settings.php");
    ob_end_flush();
    ?>
    Oh.. I've miss-spelled the table I thought it was "guildtech" but it was GUITech, so the I've changed GUITech inside the script to guildtech so it should work now..
    And BTW you need to have a settings.php because after this script has been ran, it's going to redirect you to settings.php (that's what header(""); does..)

    The SQL that I have for this is:

    Code:
    -- phpMyAdmin SQL Dump
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    --
    -- Database: `guild`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `guidtech`
    --
    
    CREATE TABLE IF NOT EXISTS `guidtech` (
      `code` varchar(20) NOT NULL,
      `user` varchar(25) NOT NULL,
      `nickname` varchar(25) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    --
    -- Dumping data for table `guidtech`
    --
    
    INSERT INTO `guidtech` (`code`, `user`, `nickname`) VALUES
    ('7f24d240521d99071c93', '', '');
    Hope that works, if not then sorry :P

    I tested it and it redirected me to settings.php so hopefully it'll do the same for you.



Advertisement