Jump to content

dharm

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Posts posted by dharm

  1. Hi, can anyone give me some advice? i have a script where a user can upload images to different albums.

     

    should i upload the images under one folder or multiple sub directories?

     

    e.g.

     

    Option 1:  images/imgID.jpeg (images/000123001cat.jpeg)

    Option 2:  images/userID/imgID.jpeg (images/000123/001cat.jpeg)

    Option 3:  images/userID/albumID/imgID.jpeg (images/000123/001/cat.jpeg)

     

    If i choose option 3 would'nt that make it difficult to manage, say if i wanted to delete or even transfer all images to a different loction, i would need to move all folders too?

     

    You advice would be much appreciated.. Thx!

  2. Hi, bubblegum anarc, thanks for your response..

     

    There would be an issue with searching against the employer ID since LIKE '%{$employer_ID}' would return more than expected.

     

    so if i had rows like..

     

    000001000001

    000010000010

    000100000100

    001000001000

    010000010000

     

    and i search for

     

    $employer_ID = "000100";

    employer ID LIKE '%{$employer_ID}'

     

    my return would be the one row 000100000100.

     

    could you please tell me how it would get more results then expected?

     

  3. Hi, i have designed a database generally without using auto instruments..

     

    Users have an option to create and account from 2 different options "employee" or "employer". each will be given a 6 digit account number which is stored as a CHAR(6). when both members interact, for example exchange messages, the messages table will have an unique id called id_id CHAR(12) made up from both employeeID and employerID (000001000001).

     

    Will it be ok to use the LIKE command to extract a message. so if i wanted all messages from a employee i would do this: WHERE id_id LIKE '".$employeeID."%'

     

    i have tested the structure so far with a few members interacting but i would like to get reassurance that this way of identifying rows will work on a larger scale?

     

    any advice would be much appreciated ..

     

    thank you

  4. Hi, im having some trouble with this bit of code. im sure its an easy fix but i cnt seem to put my finger on it.

    $catline = "222,223,224,225,";

     

     

    WHERE cat IN ('".substr(str_replace(",","','", $catline),0,-3)."')

     

    Any suggestions will be much appreciated.

     

    thx!

  5. Looks good!! i would maybe increase the font size for your headdings University Restructure, Programmes and so on.. Try a light background image (logo) it might make it look bit more busy.. 
  6. Hi, i am having trouble with this bit of code. Im trying to get records from two different message tables "Q_Qestion" and "Msg_b". My aim is to display all New messages in Date order. But i seem to be getting all new messages displayed X 3!. Can anyone tell me where im goin wrong? thanks!

     

    $q = "SELECT q_questions.id, q_questions.date, q_questions.question, msg_b.id_project_id, msg_b.date_time, msg_b.msg FROM 
    ".$DBprefix."msg_b, q_questions WHERE q_questions.id2_id2 LIKE '%".$row['id']."' AND(/OR not sure!) msg_b.id3_id3 LIKE '".$row['id']."%'  AND msg_b.isRead='1' ORDER BY msg_b.date_time, q_questions.date";
    
    $r = mysql_query($q); if (mysql_num_rows ($r)==0) {echo "<center>(Currently no messages!)</center><br>";} else { 
    while ($rmsg = mysql_fetch_array($r)) {  
    echo $rmsg['question'];
    } 

     

    outputs:

     

    message 1

    message 1 ( duplicated! this is not needed )

    message 1 ( duplicated! this is not needed )

     

    message 2

    message 2 ( duplicated! this is not needed )

    message 2 ( duplicated! this is not needed )

  7. Hi. I was wondering if anyone could help me with this jump menu.. The jump menu is part of a form that includes other fields which make up a search page. The jump menu works fine but the problem is with the other input text fields.. if for example when I input data in any of the other fields then select a option from the jump menu the page will refresh but the data from the text fields I entered will not appear..

    Is there a way where I can save the data from the forms when the jump menu re-loads the page?.. Or is there a better alternative then using an old fashion jump menu ..? 

    Here is the code:

    [quote]<select name="category" onChange="window.location = this.options[this.selectedIndex].value">
    <option value="search.php">Any</option>
    <option value="search.php?cats=1">1</option>
    <option value="search.php?cats=2">2</option>
    </select>[/quote]

    Any help will be much appreciated… 
  8. Hi, im trying to find a way where I can get the highest profile_id number from a group of profiles owned by a particular user..The table “profiles” also contains other users profile(s). here is the part of the code im workin with:

    [quote] <?php $query = "Select MAX(profile_no)  from ".$DBprefix."profiles GROUP BY where pro_id='$cid'"; // $cid is the users unique account number. ?> [/quote]

    any help will be much appreciated .. thx!
  9. I have written this code but im having trouble making it work. This code is to check weather a part of a needle is present within haystack. I think the problem maybe when thrs more then one mysql result checked. This code is to help prevent inserting data into the database more then once if the refresh button is pressed. Here is the code:

    [code]<?php // check discription string within $basevar if is present in database
    $query2 = "Select * from ".$DBprefix."protable where client_id='$cid' and off_date='0'";
    $result2 = mysql_query($query2); $pos[] = array();

    while($row1 = mysql_fetch_array($result2)){
    $discription = $row1["discription"];
    $mystring = $basevars;
    $pos[] = strpos($mystring, $discription);}

    $num = count($pos);
    for ($i=0;$i<$num;$i++) {
    if ($pos[$i] === false ){} else{
    echo $pos[1]; // checkin output
    echo"<h1>Data Already complete</h1>;

    include("../../includes/footer.php");
    exit();}} ?> [/code]

    Any help will be much appreciated!

    Thxs

    dharm
  10. Thx!..Got it working.. but if I place each part of the array into separate variables (see blow) and then pass it through a URL it doesn’t work.. can I make this work? Or do I need to pass the array from form to form?

    Here is the code…

    [code]<html>
    <head>
    <title>File Upload Form</title>
    </head>
    <body><? if (!isset($action)) {?>
    This form allows you to upload a file to the server.<br>

    <form action="getfile.php" enctype="multipart/form-data" method="post"><br>
    Type (or select) Filename: <input type="file" name="uploadFile">
    <input type="hidden" name="MAX_FILE_SIZE" value="25000" />
    <input type="hidden" name="action" value="fghgf" />
    <input type="submit" value="Upload File">
    </form>

    </body>
    </html>
    <? } ?>
    <? if ($action=="fghgf") {
    $filename1 = $_FILES['uploadFile']['name'];
    $filetmp1 = $_FILES['uploadFile']['tmp_name'];
    $filesize1 = $_FILES['uploadFile']['size'];
    $fileerror1 = $_FILES['uploadFile']['error'];

    header("Location: getfile.php?filename1=$filename1&filetmp1=$filetmp1&filesize1=$filesize1&fileerror1=$fileerror1&action=upload");

    }
    ?>
    <?php
    if ($action=="upload") {
    ?>
    <html>
    <head>
    <title>Process Uploaded File</title>
    </head>
    <body>
    <?

    if ( move_uploaded_file ($filetmp1,
          "Home/uploads/{$filename1}")  )
          {  print '<p> The file has been successfully uploaded </p>';
          }
    else
          {
            switch ($fileerror1)
            {  case 1:
                      print '<p> The file is bigger than this PHP installation allows</p>';
                      break;
                case 2:
                      print '<p> The file is bigger than this form allows</p>';
                      break;
                case 3:
                      print '<p> Only part of the file was uploaded</p>';
                      break;
                case 4:
                      print '<p> No file was uploaded</p>';
                      break;
            }
          }
    ?>
    </body>
    </html>
    <? } ?>[/code]

    ..Output is a blank screen with vars showing correctly in URL

    Any help will be much appreciated. 
  11. Hi, I am having trouble with a simple upload file script and would appreciate any help.. Could anyone tell me how I could make files upload to my localhost (for testing)..

    here is the script..

    <html>
    <head>
    <title>File Upload Form</title>
    </head>
    <body><? if (!isset($action)) {?>
    This form allows you to upload a file to the server.<br>

    [code]<form action="getfile.php" method="post"><br>
    Type (or select) Filename: <input type="file" name="uploadFile">
    <input type="hidden" name="MAX_FILE_SIZE" value="25000" />
    <input type="hidden" name="action" value="fghgf" />
    <input type="submit" value="Upload File">
    </form>

    </body>
    </html>
    <? } ?>
    <? if (isset($action)) {?>
    <html>
    <head>
    <title>Process Uploaded File</title>
    </head>
    <body>
    <?php
    echo $_FILES['uploadFile'] ['name'];
    if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
          "Home/uploads/{$_FILES['uploadFile'] ['name']}")  )
          {  print '<p> The file has been successfully uploaded </p>';
          }
    else
          {
            switch ($_FILES['uploadFile'] ['error'])
            {  case 1:
                      print '<p> The file is bigger than this PHP installation allows</p>';
                      break;
                case 2:
                      print '<p> The file is bigger than this form allows</p>';
                      break;
                case 3:
                      print '<p> Only part of the file was uploaded</p>';
                      break;
                case 4:
                      print '<p> No file was uploaded</p>';
                      break;
            }
          }
    ?>
    </body>
    </html>
    <? } ?>[/code]
    here is the output..

    Notice: Undefined index: uploadFile in c:\easyphp1-7\www\getfile.php on line 27

    Notice: Undefined index: uploadFile in c:\easyphp1-7\www\getfile.php on line 28

    Notice: Undefined index: uploadFile in c:\easyphp1-7\www\getfile.php on line 29

    Notice: Undefined index: uploadFile in c:\easyphp1-7\www\getfile.php on line 34
  12. Hi, im a noob to this and would like some help with sorting categories. I have a table with 2 columns CATS and SUBCATS.

    --------------------------------------
    | CATS  | SUBCATS                      |
    --------------------------------------
    | c1      | sub1.1, sub1.2, sub1.3    |
    ------------------------------------ |
    | c2      | sub2.1, sub2.2, sub2.3,    |
    |          | sub2.4                          |
    -------------------------------------                               
    | c3      | sub3.1, sub3.2 ....
    -------------------------------------

    A user selects a main category from a previous page(see below for code) then this data is passed to here where I want to use the categories row number and I want to explode a selected row from SUBCATS and divide all the content where “,” is and sort them within radiobuttons. Here is the code I have:

    [code] echo "<strong>$cat</strong><br><p>";
     
    $query1 = "Select * from ".$DBprefix."categories";
    $r = mysql_query($query1);
    $numrow=mysql_num_rows ($r);

    for ($i=0;$i<$numrow;$i++)
    {
    $row = mysql_fetch_row($r);
    ?>
    <input type="radio" name="category[]" value="<? echo $row[1]; ?>"> <? echo $row[1]; ?><br>
    <?php
    }[/code]

    this outputs:

    [b]c1[/b]

    (0) sub1.1, sub1.2, sub1.3
     
    (0) sub2.1, sub2.2, sub2.3, sub2.4
    (0) sub3.1, sub3.2


    This is the code from previous page:

    [code]$query1 = "Select * from ".$DBprefix."categories";
    $r = mysql_query($query1);

    $numrow=mysql_num_rows ($r);

    for ($i=0;$i<$numrow;$i++)
    {
      $field =  mysql_fetch_field($r);
      $tfields[$i] = $field->name;
    }
    while ($row = mysql_fetch_row($r))
    {echo "<br><p>";
      $rowAssoc = Array();
      for ($i=0;$i<$numrow;$i++)
      { 
      for ($i=0;$i<1;$i++){
      // print the title of catogory
      $text= ("<a href=\"page2.php?cats=$row[0]\"><strong>$row[0]</strong></a><br>");
          }
      $rowAssoc[$tfields[$i]] = $row[$i];

      foreach(explode(",",substr($rowAssoc[$tfields[$i]],0)) as $vi)
        //print the subcats dividing with a :
    $text= ("$text<a href=\"page2.php?cats=$row[0],$vi\">$vi</a> : ");
      if ($i=$numrow) {$text= "$text.";}
      echo str_replace(": ."," ", $text);
    }}[/code]

    I know I need to use foreach, explode and maybe substr bt im not sure which order to put them in.
    Any help would be much appreciated. Thx! 
  13. Hi, can anyone help!.. im trying to check the characters of a username and password but cant seem to check the whole field, only the first letter. Here is the code
    Please tell me where im going wrong..

    $UserNameGood = chk_chars($username1);
    //}
    if ($UserNameGood == true) {
    echo "username is good";
    }else {
    echo "username is bad";
    }
    // $PassWordGood = chk_chars($password1);

    function chk_chars($inputVar) {

    $charsGood = true;
    if (!ereg("^[A-Za-z0-9_-]",$inputVar))
    {
    $charsGood = false;
    }
    return $charsGood;
    }

    Thx!
  14. thank you poirot!... Does anyone know how i could also check for the ID code within another table aswell as client_info.. whas the best way to structure this? thx. [quote]thank you!... Does anyone know how i could also check for the ID code within another table aswell as client_info.. whas the best way to structure this? thx.
  15. Hi I have this script that calls the most recent ID number from mysql using last_insert_id() but I would like to add 1 to make a new ID. For some reason when I try to add 1 to my six digit ID it returns less numbers.. for example ID is 000123. if I add 1 to 000123 I get 124. Im not sure if im using the right method.. Here is the code, any help would be much appreciated.

    [code]$query1 = "Select *, last_insert_id() from ".$DBprefix."client_info ORDER BY `id` DESC LIMIT 1";
    $result = mysql_query($query1);
    if (mysql_errno())
    {
    die("<br>" . mysql_errno() .": ".mysql_error()."<br>");
    }
    $row = mysql_fetch_row($result);
    if (mysql_errno())
    {
    die("<br>" . mysql_errno() .": ".mysql_error()."<br>");
    }
    $newid = $row[0];
    echo "<br>Assigned ID: $newid"; // this echos 000123

    $newid++;

    echo "$newid";  // this echos 124[/code]

    Thx.
×
×
  • 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.