Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. Your html is very difficult to read. You should clean it up.

    [code]
    <table class="main" cellpadding="0" cellspacing="10" align="center">
        <tr>
            <td><h1>Base + Parts Dashboard</h1></td>
        </tr>
        <tr>
            <td><form name="partgen" action="index.php?i=99" method="post">
                <table class="quick" cellpadding="0" cellspacing="10" align="center" width="450">
                    <tr>
                        <td colspan="3" valign="top"><h2>Parts Management</h2></td>
                    </tr>
                        
                    <tr>
                        <td valign="top">Select Base(s):</td>
                        <td><select class="drop" name="field[part_base_id][]" multiple="multiple" size="5">
                                <?=selectgen('base');?>
                            </select>
                        </td>
                        <td><input name="name[part_base_id]" type="hidden" value="Select Base(s)" /></td>
                    </tr>
                    <tr>
                        <td valign="top">Select Make(s):</td>
                        <td><select class="drop" name="field[part_make_id][]" multiple="multiple" size="5">
                                <?=selectgen('make');?>
                            </select>
                        </td>
                        <td><input name="name[part_make_id]" type="hidden" value="Select Make(s)" /></td>
                    </tr>
                    <tr>
                        <td>Kit Count:</td>
                        <td><input type="text" name="field[part_kit_count]" class="text"/></td>
                        <td><input name="name[part_kit_count]" type="hidden" value="Kit Count" /><b>i.e 2</b></td>
                    </tr>
                    <tr>
                        <td colspan="3" align="center"><input type="submit" name="submit" value="Submit" class="submit" /></td>
                    </tr>
                </table>
                <input name="table" type="hidden" value="part" />
                <input name="key" type="hidden" value="part_id" />
                </form>
            </td>
        </tr>
    </table>
    [/code]

    Do a print_r on $_POST to see how it looks.
  2. This will get you started.

    You will need to make sure that the cURL extension is enabled.

    [code]$page = "http://en.wikipedia.org/wiki/PHP";

    function processURL($url){
           $url=str_replace('&amp;','&',$url);
           $ch=curl_init();
           curl_setopt($ch, CURLOPT_URL, $url);
           curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
           $xml = curl_exec ($ch);
           curl_close ($ch);
           echo $xml;
    }

    echo processURL($page);[/code]

    Read the manual pages on cURL as well:

    [a href=\"http://www.php.net/curl\" target=\"_blank\"]http://www.php.net/curl[/a]
  3. Assuming that the post values have numeric keys (for the profile ids) you can do something like this:

    [code]    foreach ($_POST as $key => $value) {
            if (is_numeric($key) && $value != "") {
                $query = 'UPDATE '.USER_PROFILE_FIELDS_TABLE.'
                                SET profile_value = "'.$value.'"
                                  WHERE user_id = "'.$auth->userdata['user_id'].'"';
                $db->db_action($query);
            }
        }[/code]

    It would eliminate a lot of your queries...you wouldn't be doing one even for the empty values...unless you want to updated with empty values, then just remove the '&& $value != ""'
  4. try this:

    [code]<?php

    include 'library/config.php';
    include 'library/opendb.php';

    $id = $_GET['id'];

    if ($id == "") {
        $query  = "SELECT id, name, path, title FROM upload2";
        $result = mysql_query($query) or die('Error, query failed');
        while(list($id, $name, $path) = mysql_fetch_array($result)) { ?>  
            <a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?= $id; ?>"><?= $title; ?></a> <br>
            <?php
        }
    } else {
        $query = "SELECT name, path, title FROM upload2 WHERE id = '$id'";
        $result = mysql_query($query);
        $r = mysql_fetch_array($result, MYSQL_ASSOC);
        ?>    
                <div align="center">
                <OBJECT ID="mediaPlayer" WIDTH="320" HEIGHT="280"
                CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
                CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 STANDBY="Loading Microsoft Windows Media components..." TYPE="application/x-oleobject" VIEWASTEXT>
                <PARAM name="autoStart" value="true">
                <PARAM name="url" value="<?= $r['path']; ?>">
                <PARAM name="wmode" value="transparent">
                <PARAM name="uiMode" value="full">
                <PARAM name="loop" value="false">
                <EMBED NAME="EmbedmediaPlayer" TYPE="application/x-mplayer2" SRC="<?= $r['path']; ?>"
                WIDTH="320" HEIGHT="280"></EMBED>
                </OBJECT>
        <?php
    }    
    mysql_close();
    ?>[/code]
  5. [!--quoteo(post=349366:date=Feb 25 2006, 03:31 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Feb 25 2006, 03:31 PM) [snapback]349366[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    What exact error are you getting?
    [/quote]

    Turn on error reporting if necessary:

    [code]ini_set("error_reporting", "1");
    ini_set("display_errors", "E_ALL");[/code]
  6. What is the common field between them? In other words, how are you linking the customers to their case and vice versa?

    case(caseID,priority,created,subject)
    customer(custID,name,surname,phone, [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]caseID[!--colorc--][/span][!--/colorc--])

    [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]FROM[/color] [color=orange]customer[/color] [color=green]LEFT[/color] [color=green]JOIN[/color] case ON customer.caseID [color=orange]=[/color] case.caseID [!--sql2--][/div][!--sql3--]

    [code]$result = mysql_query($query);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
      echo "
      <tr>
        <td>CASEID  = $row[caseID]</td>
        <td>PRIORITY   = $row[pritority]</td>
        <td>CREATED   = $row[created]</td>
        <td>SUBJECT   = $row[subject]</td>
        <td>NAME   = $row[name]</td>
        <td>SURNAME   = $row[surname]</td>
        <td>PHONE  = $row[phone]</td>
      </tr>";
    }[/code]
  7. What exact error are you getting?

    Offhand, it could be a couple of things...

    1. The file you are uploading is too big and doesn't get uploaded. By default, the limit is set to 2048kb.

    2. The script is using too much memory. I've encountered this before when working with very large jpgraph graphs. By default a script is limited to occupying 8MB (maybe 16, but I think 8) of memory, if you have a very large pic, then as it's doing it's resizing functions on it, it may be going above that.
  8. This should work. You'll probably have to adjust it some to make it display where you want.

    Is there a reason you are putting all of your html into functions?

    [code]<?php

    require("functions.php");
    include("dbconnect.php");

    session_start();

    head1();
    body1();
    new_temp();
    sotw();
    navbar();
        
    $start = $_GET['start'];
    if ($start == "" || $start < 0) {
        $start = 0;
    }
    $display = 10;

    $query = "SELECT * FROM news ORDER BY id DESC LIMIT $start, $display";
    $result = mysql_query($query);

    if ($result) {
        while( $row = @mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
            news_box( $row['news'], $row['title'], $row['user'], $row['date'], $row['id'] );
        }
        mysql_free_result($result);
    } else {
        news_box( 'Could not retrieve news entries!', 'Error', 'Error', 'Error');
    }

    echo '<div style="text-align: center">';
    if ($start > 0) {
        echo "<a href=\"" . $_SERVER['PHP_SELF'] . "&start=" . $start - 10 . "\">Prev page</a>";
    }
    echo "&nbsp;&nbsp;";
    if (($start + 10) < mysql_num_rows($result);) {
        echo "<a href=\"" . $_SERVER['PHP_SELF'] . "&start=" . $start + 10 . "\">Next page</a>";
    }
    echo '</div>';
              
    footer();

    mysql_close($link);
    ?>[/code]
  9. [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>edit information</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?

    $html = '<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table width="750" border="0" cellspacing="0">
      <tr>
        <td width="395">&nbsp;</td>
        <td width="351"><div align="right">username:
              <input name="subscriber" type="text">
            <input type="submit" name="Submit" value="Submit">
          </div></td>
      </tr>
    </table><br>
    <input type="submit" name="submit" value="Submit"> ';


    if($_POST['submit'] == "Submit") {
      
       $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die('Unable to connect!');
       mysql_select_db(DB_NAME) or die('Unable to select database');

       $query = "SELECT lname, fname FROM subscriber WHERE username = '$subscriber'";
       $display = mysql_query($query) or die("Error in query: $query. " . mysql_error());

        if (mysql_num_rows($display) > 0) {
            $html = '<table width="750" border="0" cellspacing="0">'
            while($row = mysql_fetch_object($display)) {
              $html .= '
                    <tr>
                      <td colspan="2">' . $subscriber . '</td>
                  </tr>
                  <tr>
                    <td width="238">last name:
                      <input name="lname" type="text" value="' . $row[lname] . '"></td>
                    <td width="508">firstname:
                      <input name="fname" type="text" value="' . $row[fname] . '"></td>
                  </tr>';
            }
            $html .= '</table><br><input type="submit" name="submit" value="Update"> ';
        }
    }
          
    if($_POST['submit'] == "Update") {
        $query = "UPDATE subscriber SET lname = '$lname', fname = '$fname' WHERE username = '$subscriber'";
        $new = mysql_query($query) or die("Error in query: $query. " . mysql_error());
    }
    mysql_close($connection);

    echo $html;
    ?>
    </body>
    </html>[/code]
  10. [!--quoteo(post=348907:date=Feb 23 2006, 09:51 PM:name=Boerboel649)--][div class=\'quotetop\']QUOTE(Boerboel649 @ Feb 23 2006, 09:51 PM) [snapback]348907[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    It wouldn't have anything to do with the password being encrypted in the database would it?
    [/quote]

    Well, since in the code you've shown us you haven't encrypted the password in your select, then yes...that will affect it.

    When it's encrypted it becomes a different string...so you can't compare the user input password with the stored encrypted password one-to-one. You have to encrypt the user input password using the same algorithm (md5, sha1, blowfish, whatever) as it is stored in the db with, then do your select.
  11. Try this:

    [code]<?php
    $username = $_POST['username'];
    $addhours = $_POST['addhours'];
    $password = $_POST['password']; // get ALL the user input

    $res = mysql_query("SELECT * FROM members WHERE username='$username' AND password='$password'");
    if (mysql_num_rows($res) > 0) {
        // found a match
        $sql="UPDATE members
            SET user_hours= user_hours + '$addhours'
            WHERE username='$username'";
        $result = mysql_query($sql) or die(mysql_error());
    } else {
        echo "No results for that username/password combination.";
    }
    ?>[/code]

    And, obviously, make sure you are connected to the db.
  12. Well, you could use strlen to find the length of your text, then if it exceeds the length that you have determined to be one page, you could use substr to seperate out only that many characters to display, along with a "next page" link.

    Of course doing that means that it wouldn't do clean transitions. In other words, if you decided that 10000 characters was one page, and the 10000th character was in the middle of a word, it would cut that word in two.
  13. Not sure where your getting the $mail->Body from...unless you are using a self/3rd party created class to create and send emails...which could be your problem.

    the mail function allows you to include all the quotes and variables you want...just escape the quotes, and remember the difference between double and single quotes with regard to variable substitution.

    [code]$body = "this is a quote: \"some text\" \n\nfollowed by a var: $var";
    mail('you@mail.com', 'An email for you',$body);[/code]

    [a href=\"http://us2.php.net/manual/en/function.mail.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.mail.php[/a]
  14. Change your onchange to this:

    onchange="javascript: go(this, this.selectedIndex);"

    Change your JS function to this:

    <script type="text/javascript">
    function go(x, y) {
    alert (x[y].value);
    }
    </script>

    Please post your questions in the proper forum in the future...this should be in the Javascript forum.
  15. Making the assumptions that I asked about above, I think this might work for you. This will only work if your array structure remains constant.

    [code]
    <?php

    $errcount=array(array(3,array(array(31,4),array(41,4),array(51,4))),
    array(6,array(array(32,5),array(42,5),array(52,5))),
    array(10,array(array(33,6),array(43,6),array(53,6))),
    array(13,array(array(34,7),array(44,7),array(54,7))));

    ?>
    <html>

    <?php
    if ($_GET['page'] == "next") {
        $element = $_GET['element'];
        $error = $errcount[$element];
        echo 'The following Case Numbers had error code ' . $error[1][0][1];
        echo '<table border="1" cellspacing="0" cellpadding="3"><tr><td>Case Number</td></tr>';
        
        foreach ($error[1] as $e) {
            if ($i%2 == 0) {
                $bg = "#EEEEEE";
            } else {
                $bg = "#CCCCCC";
            }
            echo '<tr bgcolor="' . $bg . '">
                    
                    <td>' . $e[0] . '</td>
                </tr>';
            $i++;
        }
        echo '<table>';
    } else {
        echo '<table border="0" cellpadding="3">
            <tr bgcolor=#CCCCCC>
                <th></th>
                <th># Of Events</th>
                <th>Error Code</th>
            </tr>';
        $i = 0;
        foreach ($errcount as $C) {
            if ($i%2 == 0) {
                $bg = "#EEEEEE";
            } else {
                $bg = "#CCCCCC";
            }
            echo '
                <tr bgcolor="' . $bg . '">
                    <td><a href="test.php?page=next&element=' . $i . '">' . $i . '</a></td>
                    <td>' . $C[0] . '</td>
                    <td><a href="test.php?page=next&element=' . $i . '">' . $C[1][0][1] . '</a></td>
                </tr>';
            $i++;
        }
        echo '</table>';
    }

    ?>
    </html>[/code]

    Definatly one of the more complicated things I've done with arrays. This would be a lot easier, assuming you are creating the array in a previous step, if you made your array keys into something meaningful. You would better be able to delve into the array and tell where you are at and access the data more easily.
  16. So, your data array looks something like this:

    [code]Array
    (
        [0] => Array
            (
                [0] => 3
                [1] => Array
                    (
                        [0] => Array
                            (
                                [0] => 31
                                [1] => 4
                            )

                        [1] => Array
                            (
                                [0] => 41
                                [1] => 4
                            )

                        [2] => Array
                            (
                                [0] => 51
                                [1] => 4
                            )

                    )

            )

        [1] => Array
            (
                [0] => 6
                [1] => Array
                    (
                        [0] => Array
                            (
                                [0] => 32
                                [1] => 5
                            )

                        [1] => Array
                            (
                                [0] => 42
                                [1] => 5
                            )

                        [2] => Array
                            (
                                [0] => 52
                                [1] => 5
                            )

                    )

            )
    ...[/code]

    I see where the number of events is coming from, and I see where the error code is coming from. What does the first element of the sub-sub array represent...in the case of error code 5 above, the 32, 42, 52? Is that the case number?

    Also, will your array always follow this format? Will the like error codes always be grouped into sub arrays like above?
  17. Yes, build the form in html.

    When it displays a field based on another selection...like you described with selecting US and displaying an input for State...it is controlled by Javascript.

    [code]<script type="text/javascript">
    function showinput(country) {
      if (country == 1) {
        document.getElementById('addfield').innerHTML = 'State: <input type="text" name="state">';
      } else if (country == 2) {
        document.getElementById('addfield').innerHTML = 'Province: <input type="text" name="prov">';
      }
    }
    </script>

    <form>
    <select name="country" id="country" onchange="javascript: showinput(document.getElementById('country').selectedIndex)">
    <option></option>
    <option>US</option>
    <option>Canada</option>
    </select>
    <div id="addfield"></div>
    </form>[/code]

    That's not perfect code by any means, but you get the idea. If you know what the values are, then you can set up catches so that certain things are displayed or not displayed when the user makes a choice.
×
×
  • 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.