28, May 2012

Query Problem in in implementation of thethe My Pagina Script - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Query Problem in in implementation of thethe My Pagina Script
« previous next »
Pages: [1] Print

Author Topic: Query Problem in in implementation of thethe My Pagina Script  (Read 3037 times)
Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« on: Dec 19, 2006, 09:24:54 pm »

Hi:

I actually posted this on the php forum, but discovered afterward, that this forum is probably more to the point.  This is my first time posting to this site and I'm very glad you all are here!  This is what I posted on the other forum:

I am currently working with the My Pagina previous-next navigation script.  All was working fine until I altered the sql statement for the purpose of limiting the number of records pulled from the MySQL table I'm working with. When I run the following query in the script, all works fine:

SELECT * FROM news ORDER BY dtime DESC;

When I change it to the following:

SELECT * FROM news ORDER BY dtime DESC LIMIT 5;


I get the following error message:

Warning:  mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/magnet/public_html/NewsScript/Display/my_pagina_class.php</b> on line 90

I know this is a legitimate query because I ran it through a query analyzer and it worked fine.  Can you tell me what the problem might be?

Anne Marie
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Dec 19, 2006, 10:33:46 pm »

the limit is set by the class, just check the example:

$test->sql = "SELECT * FROM link_list ORDER BY id"; // the (basic) sql statement (use the SQL whatever you like)

and check also the comments inside the class...

Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« Reply #2 on: Dec 20, 2006, 12:20:49 am »

Hi Olaf:

I'm still a newbie with php, just need to say that!  OK.  I looked at the my_pagina_class.php page and found the $max_rows variable which the comments state is used to limit the number of records returned from the dbase.  I set that variable to 5, hoping it would limit the number of records queried, but I still got the full record set coming up.  I want to distinguish between how many records are being displayed on the page as opposed to the number I'm attempting to limit in my sql query.  I have it displaying one page at a time, using the "simple_nav_links" function - that part is working fine.  I now want to limit the number of records to cycling through to 5 records only. (These are going to be news articles and we want to limit their availability to the users to the most current 5 articles.)  Here is the URL so you can see what we're trying to do: http://magnet.caltech.edu/iFrameTest3.php.

AM
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Dec 20, 2006, 12:22:56 am »

just read the comments:

(from the config file)

// some external constants to controle the output
define("QS_VAR", "page"); // the variable name inside the query string (don't use this name inside other links)
define("NUM_ROWS", 4); // the number of records on each page

define("STR_FWD", "&gt;&gt;"); // the string is used for a link (step forward)
define("STR_BWD", "&lt;&lt;"); // the string is used for a link (step backward)

// use the rught pathes to get it working with the php function getimagesize
define("IMG_FWD", "./forward.gif"); // the image for forward link
define("IMG_BWD", "./backward.gif"); // the image for backward link

define("NUM_LINKS", 5); // the number of links inside the navigation (the default value)

Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« Reply #4 on: Dec 20, 2006, 01:14:05 am »

I apologize for double-posting.  My mistake.  I'll stick to this forum, although I just blew it again and posted the response below to the other forum.  Sorry!  For the sake of consistency, I'll post what I meant to post here earlier:

******************************

What I see in the db_config.php file is a line to limit the number of records displayed on the page:

define("NUM_ROWS", 1); // the number of records on each page.  This is set correctly for my purposes. 

The next line I see that limits something is:

define("NUM_LINKS", 5); // the number of links inside the navigation (the default value).  Since I'm using the $simple_nav_link, this doesn't appear to apply to my needs in the script.

What is not clear is why I can't seem to limit the number of records that are pulled from the database in the sql query.  I want to be able to step forward and back the most recent 5 records only.  What am I missing here?

AM
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Dec 20, 2006, 08:56:48 am »

do you have a database with many records and you want to show only the last x records? why?

Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« Reply #6 on: Dec 20, 2006, 08:29:57 pm »

That's exactly what I want to do.  The database will be the storehouse for multiple articles.  Those that are older than the most recent 5 articles will be viewable in an "archive" section of our website.  I'm trying to set things up so that I can run both the recent article display page and the archive page out of the same database table.

AM
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Dec 20, 2006, 09:39:14 pm »

That's exactly what I want to do.  The database will be the storehouse for multiple articles.  Those that are older than the most recent 5 articles will be viewable in an "archive" section of our website.  I'm trying to set things up so that I can run both the recent article display page and the archive page out of the same database table.

AM
and how many "new" articles do you wanna show?

Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« Reply #8 on: Dec 20, 2006, 09:45:37 pm »

Five.
Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


« Reply #9 on: Dec 20, 2006, 10:12:59 pm »

I ran the page with the error on it.  It's at http://magnet.caltech.edu/iFrameTest3.php?page=0.  I just noticed that the arrows are actually cycling through just 5 records (yay!), but the error message (need to look at View Source) indicates that "mysql_num_rows(): supplied argument is not a valid MySQL result resource".  Does this help ferret out what the problem might be?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Dec 20, 2006, 10:49:54 pm »

Five.
why do you need a class like this for pagination?

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Dec 21, 2006, 02:51:02 pm »

I think you're using the wrong script for this small result, try this one:

http://www.finalwebsites.com/snippets.php?id=37

Atari ST fan
*
Posts: 8
62 credits
Members referred : 0


Re: Query Problem in implementation of the My Pagina Script
« Reply #12 on: Jan 03, 2007, 12:25:44 am »

I was able to locate another script and got it working.  Thank you for your response though.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=5308
Tags : php-mysql Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Query Problem in in implementation of thethe My Pagina Script
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 07:21:39 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.