Jump to content

twm

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Posts posted by twm

  1. Well, where should I start. As you will/can tell, my first language isn't English, so I apologize for grammar and spelling. Been a sort of programmer for a while. Started in '83 then went to play soldier for a few years (in '88).

     

    Once I learned English (had no choice, ended up in Canada), I started up with programming again, and been doing it on and off for a few years now. Even got a diploma in Internet and E-Commerce Application Development. Woohoo! An other one for the office wall! Everybody has to make a living, right?

     

    Currently working as a sub contractor for a video conferencing company / network provider. Don't do much programming anymore, so it became a sort of a hobby, doing projects for companies (name dropping spot here: Intel, Orange Julius, Peek Freans and a few more smaller - bigger projects for companies (internal applications) Telemerge, IPV Gateways...etc

     

    The fave is PHP/MySQL stuff but sometimes still code .NET (but we don't talk about that). Most of my time is spent front of the computer, but it has it's upside as well. Don't have to leave the house if I don't feel up to it. Grab a beer and a smoke and have fun with some code.

     

    What do I do for fun? Write PHP scripts. J/K. I play pool in a few leagues, and get together with a few buddies for a poker game or two. (or maybe that is in the drinking beer category)

     

    Oh well, next I will learn some social skills, so I can actually talk to people about something (or at least myself). :-D

  2. part of my index2.php code...just the inventory part..

     

    <?php session_start();
    
    if(isset($_SESSION['otherusername'])){
    
    $db=mysql_connect('localhost', 'root', '');
    
    $res=mysql_select_db('textgame',$db) or die(mysql_error());
    
        
    $otherusername = "SELECT item FROM users_items WHERE username='".$_SESSION['otherusername']."'";
    echo $otherusername;
        
        $res=mysql_query($otherusername)or die(mysql_error());
        
      
        while($row = mysql_fetch_assoc($res)){
    
    
         echo $row;
      
      }
    }else{
       
       echo "Sorry your not a member please join us!";
    }
    }
    ?>

     

    insert2.php code

     

    <?php
    //ob_start();
    $host="localhost"; // Host name
    $username="root"; // Mysql username
    $password=""; // Mysql password
    $db_name="textgame"; // Database name
    $tbl_name="users"; // 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 = (isset($_POST['username'])) ? mysql_real_escape_string($_POST['username']) : FALSE;
    $password1 = (isset($_POST['password1'])) ? $_POST['password1'] : FALSE;
    $password2 = (isset($_POST['password2'])) ? $_POST['password2'] : FALSE;
    if(!$Username) die('username not set');
    if(!$password1) die('Password1 not set');
    else $password1 = md5($password1);
    if(!$password2) die('Password2 not set');
    else $password2 = md5($password2);
    $query = "SELECT * FROM users WHERE username='$Username' AND password1='$password1' AND password2='$password2'";
    $result = mysql_query($query) or die( mysql_error());
    $count=mysql_num_rows($result);
    if($count==1)
    {
    $otherusername = "SELECT item FROM users_items WHERE username='".$Username."'";
    session_start();
    //session_register("username");
    $_SESSION['Username'] = $Username;
    $_SESSION['otherusername'] = $otherusername;
    
    $result1 = mysql_query($queryy);
    $row = mysql_fetch_assoc($result1);
    $_SESSION['gold'] = $row['gold'];
    //session_register("inventory");
    $Query = "SELECT item FROM users_items WHERE username='$Username'";
    $Result = mysql_query($Query);
    $Row = mysql_fetch_array($Result);
    $_SESSION['inventory'] = $Row['item'];
      
    
    header("location:index2.php"); 
    }
    else {
    echo "Wrong Username or Password";
    }
    
    ?>

     

    should have started here...  :)

  3. try and see if anything different happens.

    <?php session_start();
    
    if(isset($_SESSION['otherusername'])){
    
    $db=mysql_connect('localhost', 'root', '');
    
    $res=mysql_select_db('textgame',$db) or die(mysql_error());
    
        
    $otherusername = $_SESSION['otherusername']; //"SELECT item FROM users_items WHERE username='".$Username."'";
        
        $res=mysql_query($otherusername)or die(mysql_error());
        
      
        while($row = mysql_fetch_assoc($res)){
    
    
         echo $otherusername;
         echo $row['item'] . "<BR />";
      
      }
    }else{
       
       echo "Sorry your not a member please join us!";
    }
    }
    ?>

  4. I find that this works better for me:

    $otherusername = "SELECT item FROM users_items WHERE username='".$Username."'";

    Make sure that you check your spelling (field name, table name ... etc) and the variable $Username exists (it isn't actually $username) and it isn't empty or NULL.

     

    And how exactly does that work better? There was nothing wrong with the way it was before.  Variables are parsed when they are put inside double quotes.

     

    they are also in single quotes inside the doubble quotes...don't know, old habbits are hard to get rid of :)

  5. I find that this works better for me:

    $otherusername = "SELECT item FROM users_items WHERE username='".$Username."'";

    Make sure that you check your spelling (field name, table name ... etc) and the variable $Username exists (it isn't actually $username) and it isn't empty or NULL.

  6. <?php 
    
    $query = "SELECT * FROM modlpae WHERE userid = '$user'";
    $result = mysql_query($query) or die('Error : ' . mysql_error());
    
    $total_questions = 15;
    $qcounter = 1;
    $filled = 0;
    
    while ($row = mysql_fetch_assoc($result)) {
    
    if(!is_null($row["q".$qcounter]) || $row["q".$qcounter] != '') {
       $filled++;
    }
    
    $qcounter++;
    
    }
    $percentage = ($filled/$total_questions)*100;
    echo $percentage;
    ?>

  7. 
    //From the php.net strtotime entry user comments:
    
    ################
    # Returns date of the Monday for given number of Iso Week(1..53)
    # and year. Output is UNIX-Timestamp
    
    <?php
    function get_monday ($week, $year="")
    {
       $first_date = strtotime("1 January ".($year ? $year : date("Y")));
       $w_day = date("w", $first_date);
       $d_week = 0;
       
       switch($w_day)
       {
       case 1:    $monday = $first_date;
           break;
       case 2:
       case 3:
       case 4:    $d_week = 604800;
       default:$monday = strtotime("Monday", $first_date)-$d_week;
       };
    
           $plus_week = "+".($week-1)." week";
    
       return (strtotime($plus_week, $monday));
    };
    
    # to use it call:
    
    date("m/d/Y", get_monday($someweek, $someyear));
    
    ?> 

  8. see if this helps:

     

    if ($_POST["form"] == "Submit"){
       
       $name = $_POST['name'];
       $startDate = $_POST['startDate'];
       $endDate = $_POST['endDate'];
       $duration = $_POST['duration'];
       $type = $_POST['type'];
       $source = $_POST['source'];
       $details = $_POST['details'];
       
          $sql = "
          INSERT INTO polyphasic (name, startDate, endDate, duration, type, source, details)
          VALUES ('$name', '$startDate', '$endDate', '$duration', '$type', '$source', '$details')
          ";
          $query = mysql_query($sql, $con);
    
          unset($_POST["form"]);
    }
    
    
    <form action="index.php" method="post">
    <tr>
    <td><input type="text" name="name" value="" /></td>
    <td><input type="text" name="startDate" value="" /></td>
    <td><input type="text" name="endDate" value="" /></td>
    <td><input type="text" name="duration" value="" /></td>
    <td><input type="text" name="type" value="" /></td>
    <td><input type="text" name="source" value="" /></td>
    <td><input type="text" name="details" value="" /></td>
    </tr>
    
    </table>
    <input type="submit" name="form" value="Submit" />
    </form>
    }

  9. ok, this worked in mysql:

     

    <?php 
    
    include ("connectdb.php");
    
    
    $sql = "CREATE TABLE `procedures` (
      `proc_id` int(11) NOT NULL auto_increment,
      `pt_id` int(11) NOT NULL,
      `proc_date` date NOT NULL,
      `procedures` varchar(20) NOT NULL,
      `proc_type` enum('GC','NS','Staff') default NULL,
      `dx` varchar(20) NOT NULL,
      PRIMARY KEY  (`proc_id`)
    )";
    
    // Execute query
    mysql_query($sql) or die(mysql_error().": $sql");
    
    
    ?>

  10. You are missing the = sign in every form element ( name\"name2\"  should be name=\"name2\" )

     

     

    <?php
    echo "
    <table cellspacing=\"0\" cellpadding=\"10\" style=\"color:#999999; font-family: arial; font-size: 13px;\">
    <tr bgcolor=\"#000\"><td align=\"right\">
    Name
    </td><td>
    <input type=\"text\" maxlength=\"20\" class=\"textfield2\" name\"name2\" value=\"$_POST[name2]\" size=\"20\" />
    </td></tr>
    <tr bgcolor=\"#333333\"><td align=\"right\">
    Company Name
    </td><td>
    <input type=\"text\" maxlength=\"20\" class=\"textfield2\" name\"company\" value=\"$_POST[company]\" size=\"20\" />
    </td></tr>
    <tr bgcolor=\"#000\"><td align=\"right\">
    Email
    </td><td>
    <input type=\"text\" maxlength=\"20\" class=\"textfield2\" name\"email\" value=\"$_POST[emalil]\" size=\"30\" />
    </td></tr>
    <tr bgcolor=\"#000\"><td align=\"right\">
    Phone Number
    </td><td>
    <input type=\"text\" maxlength=\"3\" class=\"textfield2\" name\"phone1\" value=\"$_POST[phone1]\" size=\"3\" />
    <input type=\"text\" maxlength=\"3\" class=\"textfield2\" name\"phone2\" value=\"$_POST[phone2]\" size=\"3\" />
    <input type=\"text\" maxlength=\"4\" class=\"textfield2\" name\"phone3\" value=\"$_POST[phone3]\" size=\"4\" />
    </td></tr>
    <tr bgcolor=\"#333333\"><td align=\"right\">
    Address
    </td><td>
    <input type=\"text\" maxlength=\"20\" class=\"textfield2\" name\"address2\" value=\"$_POST[address2]\" size=\"20\" />
    </td></tr>
    <tr bgcolor=\"#000\"><td align=\"right\">
    City, State
    </td><td>
    <input type=\"text\" maxlength=\"20\" class=\"textfield2\" name\"city\" value=\"$_POST[city]\" size=\"13\" />
    <input type=\"text\" maxlength=\"2\" class=\"textfield2\" name\"state\" value=\"$_POST[state]\" size=\"2\" />
    </td></tr>
    <tr bgcolor=\"#333333\"><td align=\"right\">
    Zip
    </td><td align=\"right\">
    <input type=\"text\" maxlength=\"5\" class=\"textfield2\" name\"zip\" value=\"$_POST[zip]\" size=\"5\" />
    </td></tr>
    <tr><td align=\"right\">
    </td><td align=\"right\">
    <input type=\"submit\" name=\"submit\" value=\"Submit\" />
    </td></tr>
    
    </table>
    ";
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.