SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 58
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Missing something?

    Dear member,

    I have found a pagination from here but everytime when i click on the file it tell me: Unable to locate the Correct database at this time.

    But i already have a Correct database and anything is correct then i don't know if the script have the problem,

    My Code:
    PHP Code:
    <?php

    $dbcnx 
    = @mysql_connect("fdb1.awardspace.com""loooool_lol""pass");

    if (!
    $dbcnx) {
    echo( 
    "<P>Unable to connect to the database server at this time.</P>" );
    exit();
    }

    if (!@
    mysql_select_db("tpvhc"$dbcnx) ) {
      echo( 
    "<P>Unable to locate the Correct database at this time.</P>" );
      exit();
    }

    //$limit number of results rows per page
    //$start is the start page of the numbered links 
    //$slice is the number of links either side of the current page

    if(isset($_GET['$limit'])) 
    {
    $limit 10;}
    else
    {
    $limit 3;}

    $start 1;
    $slice 5;


    //simple query which returns the total number of rows for the query 
    //so if we have 26 results in our database $totalrows will be 26
    $q "SELECT * FROM Cottage";
    $r mysql_query($q);
    $totalrows mysql_num_rows($r);


    //checks to see if the page variable has been set and that its a numeric figure
    //if it isn't then give the $page varibale a value of 1 else give it te value of the page variable from the link
    if(!isset($_GET['page']) || !is_numeric($_GET['page'])){
    $page 1;
    } else {
    $page $_GET['page'];
    }


    //round sup to the nearest whole number the totalrows(26) divided by the limit figure(3) = 8.66 so we get 9 pages
    $numofpages ceil($totalrows $limit);
    //this creates the limit statement for our sql query its page number * by limit - limit.
    //so page 1 = 1 * 3 = 3 - 3 = 0 so our sql query is 0,3
    //so page 3 = 3 * 3 = 9 - 3 = 6 so our sql query os 6,3
    $limitvalue $page $limit - ($limit);


    $q "SELECT * FROM Cottage LIMIT $limitvalue$limit";
    if (
    $r mysql_query($q)) {

    //loop results here
    echo '<table class="table">';
    echo 
    '<tr><th>Cottage ID</th><th>Cottage Name</th><th>Bedrooms</th><th>Occupants</th></tr>';
    while (
    $row mysql_fetch_assoc($r)) {
    echo 
    '<tr>';
    echo 
    '<td>' $row['Cottage_ID'] . '</td>'
    echo 
    '<td>' $row['Cottage_Name'] . '</td>';
    echo 
    '<td>' $row['Bedrooms'] . '</td>';
    echo 
    '<td>' $row['Occupants'] . '</td>';
    echo 
    '</tr>';
    }
    echo 
    '</table>';


    //if we are not on the first page give pageprev a value of $page - 1 and echo a link to the previous page and the first page
    if($page!= 1){
    $pageprev $page 1;
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page='.$pageprev.'">PREV</a> - ';
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page=1">First</a> - ';
    }


    //if the page value plus the slice value(number of links either side of current page number) is less than the number of pages
    //up to this point
    if (($page $slice) < $numofpages) {
    $this_far $page $slice;
    } else {
    $this_far $numofpages;
    }

    if ((
    $start $page) >= && ($page 5) > 0) {
    $start $page 5;
    }

    for (
    $i $start$i <= $this_far$i++){
    if(
    $i == $page){
    echo 
    "<u><b>".$i."</b></u> ";
    }else{
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$i.'">'.$i.'</a> ';
    }
    }

    if((
    $totalrows - ($limit $page)) > 0){
    $pagenext $page 1;
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$pagenext.'">NEXT</a>';
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$numofpages.'">Last</a>';
    }

    }

    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?$limit=10">10</a>';

    ?> 




    </p>
    </body>
    </html>

  2. #2
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove the @ to see any errors. Are you sure your server is fdb1.awardspace.com?

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Deleted it but still doesnt work, and also here is the direct link to the file: http://loooool.awardspace.com/pagination.php

    My code again:
    PHP Code:
    <?php

    $dbcnx 
    mysql_connect("fdb1.awardspace.com""loooool_lol""pass");

    if (!
    $dbcnx) {
    echo( 
    "<P>Unable to connect to the database server at this time.</P>" );
    exit();
    }

    if (!
    mysql_select_db("tpvhc"$dbcnx) ) {
      echo( 
    "<P>Unable to locate the Correct database at this time.</P>" );
      exit();
    }

    //$limit number of results rows per page
    //$start is the start page of the numbered links 
    //$slice is the number of links either side of the current page

    if(isset($_GET['$limit'])) 
    {
    $limit 10;}
    else
    {
    $limit 3;}

    $start 1;
    $slice 5;


    //simple query which returns the total number of rows for the query 
    //so if we have 26 results in our database $totalrows will be 26
    $q "SELECT * FROM Cottage";
    $r mysql_query($q);
    $totalrows mysql_num_rows($r);


    //checks to see if the page variable has been set and that its a numeric figure
    //if it isn't then give the $page varibale a value of 1 else give it te value of the page variable from the link
    if(!isset($_GET['page']) || !is_numeric($_GET['page'])){
    $page 1;
    } else {
    $page $_GET['page'];
    }


    //round sup to the nearest whole number the totalrows(26) divided by the limit figure(3) = 8.66 so we get 9 pages
    $numofpages ceil($totalrows $limit);
    //this creates the limit statement for our sql query its page number * by limit - limit.
    //so page 1 = 1 * 3 = 3 - 3 = 0 so our sql query is 0,3
    //so page 3 = 3 * 3 = 9 - 3 = 6 so our sql query os 6,3
    $limitvalue $page $limit - ($limit);


    $q "SELECT * FROM Cottage LIMIT $limitvalue$limit";
    if (
    $r mysql_query($q)) {

    //loop results here
    echo '<table class="table">';
    echo 
    '<tr><th>Cottage ID</th><th>Cottage Name</th><th>Bedrooms</th><th>Occupants</th></tr>';
    while (
    $row mysql_fetch_assoc($r)) {
    echo 
    '<tr>';
    echo 
    '<td>' $row['Cottage_ID'] . '</td>'
    echo 
    '<td>' $row['Cottage_Name'] . '</td>';
    echo 
    '<td>' $row['Bedrooms'] . '</td>';
    echo 
    '<td>' $row['Occupants'] . '</td>';
    echo 
    '</tr>';
    }
    echo 
    '</table>';


    //if we are not on the first page give pageprev a value of $page - 1 and echo a link to the previous page and the first page
    if($page!= 1){
    $pageprev $page 1;
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page='.$pageprev.'">PREV</a> - ';
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page=1">First</a> - ';
    }


    //if the page value plus the slice value(number of links either side of current page number) is less than the number of pages
    //up to this point
    if (($page $slice) < $numofpages) {
    $this_far $page $slice;
    } else {
    $this_far $numofpages;
    }

    if ((
    $start $page) >= && ($page 5) > 0) {
    $start $page 5;
    }

    for (
    $i $start$i <= $this_far$i++){
    if(
    $i == $page){
    echo 
    "<u><b>".$i."</b></u> ";
    }else{
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$i.'">'.$i.'</a> ';
    }
    }

    if((
    $totalrows - ($limit $page)) > 0){
    $pagenext $page 1;
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$pagenext.'">NEXT</a>';
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$numofpages.'">Last</a>';
    }

    }

    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?$limit=10">10</a>';

    ?> 




    </p>
    </body>
    </html>

  4. #4
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It means your login information is incorrect.

    $dbcnx = mysql_connect("fdb1.awardspace.com", "loooool_lol", "pass");

    Try changing fdb1.awardspace.com to localhost. Most databases don't allow remote connections. You can also echo mysql_error() to see what error is coming back.

    Also, thanks for your database login information

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, all the information is correct, i think something wrong with the script.

    waiting for reply.

    thanks

  6. #6
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure your db is called tpvhc? Check to see whether your host has a prefix.

    Also, as posted above, adjust your queries to include mysql_error() to display any errors.

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again,

    It gave me error: http://loooool.awardspace.com/pagination.php

    the errors is:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/loooool.awardspace.com/pagination.php on line 32
    - 10

    My code:
    PHP Code:
    <?php

    $dbcnx 
    = @mysql_connect("fdb1.awardspace.com""loooool_lol""pass");

    if (!
    $dbcnx) {
    echo( 
    "<P>Unable to connect to the database server at this time.</P>" );
    exit();
    }

    if (!@
    mysql_select_db("loooool_lol"$dbcnx) ) {
      echo( 
    "<P>Unable to locate the Correct database at this time.</P>" );
      exit();
    }

    //$limit number of results rows per page
    //$start is the start page of the numbered links 
    //$slice is the number of links either side of the current page

    if(isset($_GET['$limit'])) 
    {
    $limit 10;}
    else
    {
    $limit 3;}

    $start 1;
    $slice 5;


    //simple query which returns the total number of rows for the query 
    //so if we have 26 results in our database $totalrows will be 26
    $q "SELECT * FROM Cottage";
    $r mysql_query($q);
    $totalrows mysql_num_rows($r);


    //checks to see if the page variable has been set and that its a numeric figure
    //if it isn't then give the $page varibale a value of 1 else give it te value of the page variable from the link
    if(!isset($_GET['page']) || !is_numeric($_GET['page'])){
    $page 1;
    } else {
    $page $_GET['page'];
    }


    //round sup to the nearest whole number the totalrows(26) divided by the limit figure(3) = 8.66 so we get 9 pages
    $numofpages ceil($totalrows $limit);
    //this creates the limit statement for our sql query its page number * by limit - limit.
    //so page 1 = 1 * 3 = 3 - 3 = 0 so our sql query is 0,3
    //so page 3 = 3 * 3 = 9 - 3 = 6 so our sql query os 6,3
    $limitvalue $page $limit - ($limit);


    $q "SELECT * FROM Cottage LIMIT $limitvalue$limit";
    if (
    $r mysql_query($q)) {

    //loop results here
    echo '<table class="table">';
    echo 
    '<tr><th>Cottage ID</th><th>Cottage Name</th><th>Bedrooms</th><th>Occupants</th></tr>';
    while (
    $row mysql_fetch_assoc($r)) {
    echo 
    '<tr>';
    echo 
    '<td>' $row['Cottage_ID'] . '</td>'
    echo 
    '<td>' $row['Cottage_Name'] . '</td>';
    echo 
    '<td>' $row['Bedrooms'] . '</td>';
    echo 
    '<td>' $row['Occupants'] . '</td>';
    echo 
    '</tr>';
    }
    echo 
    '</table>';


    //if we are not on the first page give pageprev a value of $page - 1 and echo a link to the previous page and the first page
    if($page!= 1){
    $pageprev $page 1;
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page='.$pageprev.'">PREV</a> - ';
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?page=1">First</a> - ';
    }


    //if the page value plus the slice value(number of links either side of current page number) is less than the number of pages
    //up to this point
    if (($page $slice) < $numofpages) {
    $this_far $page $slice;
    } else {
    $this_far $numofpages;
    }

    if ((
    $start $page) >= && ($page 5) > 0) {
    $start $page 5;
    }

    for (
    $i $start$i <= $this_far$i++){
    if(
    $i == $page){
    echo 
    "<u><b>".$i."</b></u> ";
    }else{
    echo 
    '<a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$i.'">'.$i.'</a> ';
    }
    }

    if((
    $totalrows - ($limit $page)) > 0){
    $pagenext $page 1;
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$pagenext.'">NEXT</a>';
    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?limit=' $limit 'page='.$numofpages.'">Last</a>';
    }

    }

    echo 
    ' - <a href="'.$_SERVER['php_SELF'].'?$limit=10">10</a>';

    ?> 




    </p>
    </body>
    </html>

  8. #8
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The table name "Cottage" should be wrong. Are your sure your table name is correct
    Simply Sajan

  9. #9
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did found only the script from the forum so i don't know about the table, could you explain a little more please?

    thanks

  10. #10
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone?

  11. #11
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Location
    England
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your database have you got a table called Cottage?

  12. #12
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No i didn't, could you tell me how to fix a table like that?

  13. #13
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your knowledge of PHP and MySQL is insufficient. Before just copy-pasting a script you've found maybe you should make yourself more familiar with these languages.

    I strongly doubt you need a 'Cottage' table in your database if you're not missing one.

  14. #14
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Info please what code should i put or can you give me the code in a zip file?

    Much appricted

  15. #15
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to you have copy code from forum. Its seems that you are confuse what actually you want to do. First clear us what you actually want to do from this code. and also will you explain the source of the forum also.

    Quote Originally Posted by Anders1 View Post
    I did found only the script from the forum so i don't know about the table, could you explain a little more please?

    thanks
    Simply Sajan

  16. #16
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone told me here to search about the title 'pagination' and there i found the code,

    I would like a pagination with A-Z, See the demo of what i would like:

    thanks
    Last edited by Anders1; Jul 21, 2008 at 08:26.

  17. #17
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can someone help me and don't be a stingy? It is urgent if your not a stingy then help me.

  18. #18
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create table name 'Cottage' in your database with field name(Cottage_ID,Cottage_Name,Bedrooms,Occupants)
    Simply Sajan

  19. #19
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is thename of extension thanks? Can you post a zip file here so it makes it more clearly for me?

    Sorry for disturbing you but need this work sorry again.

  20. #20
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create file name createtble.php. and put the code in this file and run.
    PHP Code:
    $dbcnx = @mysql_connect("fdb1.awardspace.com""loooool_lol""pass");

    if (!
    $dbcnx) {
    echo( 
    "<P>Unable to connect to the database server at this time.</P>" );
    exit();
    }

    if (!@
    mysql_select_db("loooool_lol"$dbcnx) ) {
      echo( 
    "<P>Unable to locate the Correct database at this time.</P>" );
      exit();
    }

    $sql 'CREATE TABLE `Cottage` (
            `Cottage_ID` INT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
            `Cottage_Name` VARCHAR( 200 ) ,
            `Bedrooms` VARCHAR( 200 ),
            `Occupants` VARCHAR( 200 ),
            PRIMARY KEY ( `Cottage_ID` )
           )'
    ;
    echo 
    'Creating table: \'Cottage\'....';
    mysql_query$sql ); 
    Simply Sajan

  21. #21
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    some problems happens here: http://loooool.awardspace.com/createtble.php

    Thanks

  22. #22
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php 
    $dbcnx 
    = @mysql_connect("fdb1.awardspace.com""loooool_lol""pass");



    if (!
    $dbcnx) {

    echo( 
    "<P>Unable to connect to the database server at this time.</P>" );

    exit();

    }



    if (!@
    mysql_select_db("loooool_lol"$dbcnx) ) {

      echo( 
    "<P>Unable to locate the Correct database at this time.</P>" );

      exit();

    }



    $sql 'CREATE TABLE `Cottage` (

            `Cottage_ID` INT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,

            `Cottage_Name` VARCHAR( 200 ) ,

            `Bedrooms` VARCHAR( 200 ),

            `Occupants` VARCHAR( 200 ),

            PRIMARY KEY ( `Cottage_ID` )

           )'
    ;

    echo 
    'Creating table: \'Cottage\'....';

    mysql_query$sql ); 

    ?>
    Simply Sajan

  23. #23
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it give me: Unable to connect to the database server at this time.

    link: http://loooool.awardspace.com/createtble.php

    Please explain a little more so i can undertsnad what i gonna do.

  24. #24
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Jhyalipati,Chapagaun-9, Lalitpur, Bagmati, Nepal
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think you have this type of problem in the beginning of this thread. So how can you solve. Please made server information correct. it will work
    Simply Sajan

  25. #25
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what about zipping a file and have in it anything so i can upoad it to my host and thanking you from my buttom of heart?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •