Jump to content

wwfc_barmy_army

Members
  • Posts

    320
  • Joined

  • Last visited

    Never

Posts posted by wwfc_barmy_army

  1. It is highly likely that your variable $sect contains the word '$sect'. Echo $sql to see exactly what is in it. What is your code that is calling that function?

     

    Please DON"T use the globals keyword in your function. For what you are doing, it has no effect and it should not be used in any case.

     

    Thats what I thought but if I don't use the global part then when trying to call the returned variable on the page that I called the fuction on i get this error:

     Notice: Undefined variable: sectname in...

     

    Any ideas about that?

     

    Think I have sorted the SQl problem.

  2. Hello.

     

    I have this function:

    <?php
    function getsectfromid($sect){
    $sql="SELECT sect_name FROM sect WHERE sect_id = $sect";
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_query($result);
    
    global $sectname;
    
    $sectname = $row['sect_name'];
    
    return $sectname;
    }
    ?>

     

    Although I am getting the error:

    Unknown column '$sect' in 'where clause'

     

    I cant figure out what it's saying $sect is an unknown column as i've specified the column as 'sect' not '$sect'. Any ideas?

     

    Thanks.

     

  3. Hello.

     

    I have this rewrite code:

     

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([0-9]+)$ index.php?id=$1 [QSA,L]
    RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)$ index.php?id=$1&width=$2&height=$3 [L,QSA]

     

    It works if i go to say:

    mydomain.com/1

    but not if i go to:

    mydomain.com/1/

     

    To take care of the following slash can i just do this:

     

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([0-9]+)$ index.php?id=$1 [QSA,L]
    RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)$ index.php?id=$1&width=$2&height=$3 [L,QSA]
    RewriteRule ^([0-9]+)/$ index.php?id=$1 [QSA,L]
    RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/$ index.php?id=$1&width=$2&height=$3 [L,QSA]

     

    Would that work or cause errors?

     

    Thanks.

  4. Hello,

     

    I have this rule at the moment:

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteRule ^(.*)$ index.php?id=$1 [QSA]
    RewriteRule ^(.*)/(.*)/(.*)$ index.php?id=$1&width=$2&height=$3 [L,QSA]

     

    This is what happens with the following:

    mydomain.com/1/200/300 - Doest exactly what I want

    mydomain.com/1/ - Goes off it some wild loop of kind of a mixture of both

     

    Any ideas how i can get around this? I want 2 different rules depending on the url.

     

    Thanks for any help.

     

  5. Hi.

     

    I have this htaccess rewrite:

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteRule ^([0-9]+)/([0-9]+)$ index.php?width=$1&height=$2

     

    I keep getting a 500 error tho. I'm looking to do this kind of rewrite:

     

    mydomain.com/index.php?width=100&height=200

    to

    mydomain.com/100/200

     

    Any ideas?

     

    Thanks.

  6. Unfortunatly not, the table has duplicates of user_id, but i used the same concept and tried:

     

    SELECT * FROM table WHERE id= " . $user_id . " ORDER BY date DESC LIMIT 1

     

    I have a date column, but my next question is will it work properly? It does in the test account I have but does it actually see it as a date or just a big number?

     

    Thanks for any advice.

  7. This code is not needed at all. Just remove it

    $result2 = mysql_query("SELECT * FROM inputs WHERE user_id = " . $userid); 
    if(!$result2){ die("Error quering the Database: " . mysql_error());}
    $total_items = mysql_num_rows($result2); 
    echo "Total Number of records in Database: " . $total_items;

     

    Everything else is fine. However the code could be tidied up a bit.

     

    But i need that code there to be able to get the total number of records at the top of the page.

  8. Here we go:

     

     
    <?php
    $result2 = mysql_query("SELECT * FROM inputs WHERE user_id = " . $userid); 
    if(!$result2){ die("Error quering the Database: " . mysql_error());}
    $total_items = mysql_num_rows($result2); 
    echo "Total Number of records in Database: " . $total_items;
    
    $limit= $_GET['limit'];
    $page= $_GET['page'];
    
    //Set default if: $limit is empty, non numerical,
    
    //less than 10, greater than 50
    
    if((!$limit)  || (is_numeric($limit) == false)
                || ($limit < 10) || ($limit > 50)) {
         $limit = 5; //default
    }
    
    //Set default if: $page is empty, non numerical,
    //less than zero, greater than total available
    
    if((!$page) || (is_numeric($page) == false)
             || ($page < 0) || ($page > $total_items)) {
          $page = 1; //default
    }
    
    //calcuate total pages
    $total_pages = ceil($total_items / $limit);
    $set_limit = ($page * $limit) - $limit;
    
    echo '' . $set_limit . '';
    
    ?>
    
      <table width="80%" border="1"  class="sortable">
      <thead>
    ////////
    ////////.. Table Headers ...
    ////////
        </thead>
        <?php
          $sql = "SELECT * FROM inputs WHERE user_id = " . $userid . " LIMIT " . $set_limit . ", " . $limit;  
      $result = mysql_query($sql) or die(mysql_error());
    while($row = mysql_fetch_array($result)){
    //
    //...Some outputs...//
      ?>
        <tr>
    //...Some outputs...//
        </tr>  
    <?php
      }
      echo "</table>";
      
    //prev. page:
    
    $prev_page = $page - 1;
    
    if($prev_page >= 1) {
    echo("<a href='?limit=$limit&page=$prev_page'><< Prev</a>");
    }
    
    //Display middle pages:
    
    for($a = 1; $a <= $total_pages; $a++)
    {
    if($a == $page) {
    echo(" $a | "); //no link
    } else {
    echo(" <a href='?limit=$limit&page=$a'>$a</a> | ");
    }
    }
    
    //next page:
    
    $next_page = $page + 1;
    if($next_page <= $total_pages) {
    echo("<a href='?limit=$limit&page=$next_page'> Next > > </a>");
    }
      ?>
    

  9. Hello.

     

    I have this piece of code:

     

    $result2 = mysql_query("SELECT id FROM mytable WHERE user_id = " . $userid); 
    if(!$result2){ die("Error quering the Database: " . mysql_error());}
    $total_items = mysql_num_rows($result2); 
    echo "Total Number of records in Database: " . $total_items; 

     

    It works, but is producing a much larger value than the database is. The value from the code above is showing 80 on page 1 and 85 on page 2. (should be exactly the same) and the table only shows 5 on page 1 and 3 on page 2.

     

    They are using virtually the same sql (the table using a wildcard to get all records)

     

    Can anyone see what I'm doing wrong?

     

    I used a tutorial similar to this to create pagination if that helps:

    http://mtbud420.com/?p=76

     

    Thanks.

  10. Hello.

     

    I have this code:

    Options +FollowSymLinks 
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([^/]+)?/?$ index.php?do=$1 [L,QSA]

     

    Which works fine for what i need it for eg: www.mydomain.com/google.com

     

    but if i want to show a subdirectory they it messes it up eg mydomain.com/subdirectory/ UNLESS i use eg mydomain.com/subdirectory/index.php.

     

    Any ideas how i can allow subdirectories?

     

    Thanks.

  11. Hello.

     

    I have a database with two tables, car makes and car models.

     

    The car makes is setup like this:

    make_id | make_name

    1            ford

     

    etc etc

     

    car models is setup like this:

    model_id | make_id | model_name

    1              1            mustang

     

    etc etc

     

    I've got a dropdown box with all the makes in, but when a make is chosen i need it to activate another text box and display the models for that make_id.

     

    Any suggestions on how i might do this?

     

    thanks.

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