Jump to content

Warz

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts posted by Warz

  1. Yes, I guess you're right about that,

     

    so far what I worked out is this formula, but to be honest I'm not that great with math, and there seems to be a lot of issues and it's only half working:

    /**
    * This function returns the new "index" value to be used based on the new "per page" value
    */
    function calculatevalue($index,$total_rows,$per_page,$old_per_page)
    {
                if ($index > $total_rows)
                {
                    return 0;
                }
    return ceil(($index+$old_per_page)/$total_rows)*$per_page;
    }
        

  2. Thanks, but I already got a working pagination class.. I just need this specific case to work

     

    function calculatevalue($index,$total_rows,$per_page) {
                if ($per_page > $index)
                {
                    return 0;
                }
                else
                {
                    // Need code here to solve issue...
                    return $index;
                }
    }

  3. Hi,

     

    I'm working on a pagination for my site and I'm having some trouble finding a function.

     

    To explain the function, you need to know that user can choose to display "any amount of rows per page"

     

    I'm using an index to determine which page user are on.  For instance if rows per page is 2 and index is 0 then I'm on page 1. Basically here is two examples:

     

    Per page: 2

    IndexPage

    01

    22

    43

    64

     

    Per page: 5

    IndexPage

    01

    52

    103

    154

     

    Ok, so here's the thing: say if index is 14 and per page is 2 and then I change to per page 10, well then we can't use 14 as index anymore, since valid index is only 0,10,20,30 and so on... I would need to make 14 --> 10

     

    Now, I'm not sure what is the best way to calculate this....or what functions to use?

  4. Hi,

     

    you need to create the viewstock.php page yourself...

     

    After any php file you can add ?anything=variable - this is simply to send variables to another page. You can add many variables by using &... example: ?name=john&age=20&userid=28294

     

    then you can get these variables on the page you visit. Say you link to viewstock.php?name=john&age=20&userid=28294

     

    then you can create viewstock.php and get these variables like this:

    <?php
    $username = $_GET['name'];
    $userage = $_GET['age'];
    $userid = $_GET['userid'];
    ?>

     

    Now you can also use these variables to make a new SQL query and get stock info (viewstock.php?id=10242):

    <?php
    $stockid = $_GET['id'];
    $sql = "select * from stocks WHERE id = ".mysql_real_escape_string($stockid)."";
    $res = mysql_query($sql);
    ....
    
    ?>

  5. for ($i=0; $i < $num_results; $i++) {
          $row = mysql_fetch_assoc ($result);
          echo '<tr><td>';
          echo '<p><strong>'.($i+1).'.</td><td>';
          echo htmlspecialchars(stripslashes($row['title']));
          echo "</strong></td><td>";
          echo '<a href="viewstock.php?id='.stripslashes($row['cxcode']).'">View</a>';
          echo '</td><td>';
          echo stripslashes($row['reldate']);
          echo '</td><td>';
          echo stripslashes($row['strtdate']);
          echo '</td><td>';
          echo stripslashes($row['enddate']);
          echo '</td><td>';
          echo '<form action="stckprofile.php"><input type="submit" value="View" name="stckview"></form>';
          echo '</td><td>';
          echo '<form action=""><input type="submit" value="Delete" name="stckdel"></form>';
          echo '</td>';

     

    Then on viewstock.php you just need to get the variable like this:

    $cxcode = $_GET['id'];

  6. You could make arrays in your form like this:

    <input type="text" name="text[1]" />
    <input type="text" name="text[2]" />
    <input type="text" name="text[3]" />
    <input type="text" name="text[4]" />

     

    ...and do like this:

    <?php
    
    $arr=$_POST['text'];
    $i=0;
    foreach ($arr as $key => $value) {
          if ($value != "")
          {
                $variables[$i] = $value;
          }
    $i++;
    }
    // implode:
    $list = implode(",", $variables);
    ?> 

  7. Your incoming variables probably don't have any value in them, have you checked?

    Yes, they both have values, however global $a; doesn't seem to get any values.... when I go "echo $a;" inside the function it echos out nothing, however outside the function it works... so the problem has to do with the fact that "global" some how doesn't work.

    And you probably have a register_globals problem. Either you have some way out of date code that is relying on register_globals to magically populate variables and register_globals are off or you have some same name post/get/cookie/session/general variables with the same name and register_globals are on and the variables are overwriting each other. Could also be a short open tag problem and part of your code is not being parsed as php code.

     

    It would taking seeing your actual code in order to tell you exactly why it is not working.

    Well register globals are off. I'm not sure which setting would magically populate my variables tbh. And one more thing, this might not be a server issue after all. I just tried creating a 100% blank php file and filled it with this script and it worked... So then obviously it must be something that my current script is causing... I havn't made that script myself and it's pretty huge. To make sure there isn't any conflicts between variables I named them something completely random like "hadwawiodhawo" and "hadoakwdjowjwo" and still didn't work. Now it must be said that I'm including this code that doesn't work correctly on a template page, maybe there are some issues here. I might just have to do it the hard way but not using globals  :'(
  8. If I understand you correctly this is what you need to do

    in <form> you choose action="" this will send request to same page... then you can either include the upload.php script on your page or simply copy the code over. Then check if user has submitted.

     

    Assuming post value look like this <input type="submit" name="submit" value="Upload">

    Example:

    if (isset($_POST['submit'])) // Has user submitted/uploaded yet?
    {
    include 'upload.php'; // If so, let's include this page
    }
    else // if not....
    {
    Place your original page here... the one user will see before (and after) uploading.
    }

  9. Hi,

     

    After I changed server, php global variable in functions didn't work anymore!?

    See this code:

     

    $a = 1;
    $b = 2;
    
    function Sum()
    {
    global $a, $b;
    $sum = $a + $b;
    return $sum;
    } 
    
    $sum = Sum();
    echo "Result is: ".$sum;

     

    Now I get: "Result is: 0"

     

    On my old server I got "Result is: 3"...

     

    Anyone know what this could be?  :confused:

     

    Old server: PHP Version 5.2.9

    New server: PHP Version 5.1.6

  10. If there are no css tags you will have to do styling by the tags php has to offer.. or you can edit the php code.

     

    Try first line after <?php to add:

    echo '<link href="http://UrlToYourCssFiles.com/style.css" rel="stylesheet" type="text/css">
    ';

     

    Then you can use that css file to style your page.

  11. Here is result from your script:

    DEBUG

     

    array(20) {

      ["url"]=>

      string(37) "http://dcl.vg.to/fetchme.php?id=11602"

      ["content_type"]=>

      NULL

      ["http_code"]=>

      int(0)

      ["header_size"]=>

      int(0)

      ["request_size"]=>

      int(0)

      ["filetime"]=>

      int(-1)

      ["ssl_verify_result"]=>

      int(0)

      ["redirect_count"]=>

      int(0)

      ["total_time"]=>

      float(0)

      ["namelookup_time"]=>

      float(0)

      ["connect_time"]=>

      float(0)

      ["pretransfer_time"]=>

      float(0)

      ["size_upload"]=>

      float(0)

      ["size_download"]=>

      float(0)

      ["speed_download"]=>

      float(0)

      ["speed_upload"]=>

      float(0)

      ["download_content_length"]=>

      float(-1)

      ["upload_content_length"]=>

      float(-1)

      ["starttransfer_time"]=>

      float(0)

      ["redirect_time"]=>

      float(0)

    }

     

  12. OMG OMG!.... How can I forget something like that  :facewall: :facewall: :facewall: :facewall:

    Thank you! yes it must have been DNS issue... I had forgotten to remove the dns records from my old server  ::)

     

    Now there is a new error displaying instead:

    Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/dvdcover/public_html/customscripts/file_get_contents_test.php on line 4

     

    Warning: file_get_contents(http://dcl.vg.to/fetchme.php?id=11602) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/dvdcover/public_html/customscripts/file_get_contents_test.php on line 4

  13. Well the server your connecting to seams okay, as the connection is valid

    Date: Wed, 07 Oct 2009 14:53:12 GMT

    Server: Apache/2.2.3 (Red Hat)

    X-Powered-By: PHP/5.1.6

    Content-Length: 313

    Connection: close

    Content-Type: text/html; charset=UTF-8

     

    200 OK

     

    the server your running dvdcoverlinks.com on did it used to work and have you changed anything as i would suggest checking that allow_url_fopen is enabled in PHP.INI configuration file.

    allow_url_fopen = On

     

    also try another URL see if its any URL or just that one

    Yes allow url fopen is on. Other URLs work. Well, not really all of them...

     

    The reason I made this file in the first place was because :

    http://dcl.vg.to/details.php?image_id=11602 <--- works, can be fetched

    http://dcl.vg.to/details.php?image_id=11605 <--- does NOT work, cannot be fetched

     

    When I enter http://dcl.vg.to/details.php?image_id=11605 it fetched http://dcl.vg.to instead!

     

    Isn't that strange? Those pages are completely identical (except from a few different values), yet when I try to fetch the 11605 one I'm redirected to main page? Doesn't make any sense at all  :confused:

     

    That's why I made this new file, to see if I could figure out what was wrong, and then I'm getting that error...  :confused:

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